1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
5 * Author: Zach Brown <zab@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/version.h>
24 #include <linux/module.h>
27 #define DEBUG_SUBSYSTEM S_PTLBD
29 #include <linux/obd_support.h>
30 #include <linux/obd_class.h>
31 #include <linux/lustre_debug.h>
32 #include <linux/lprocfs_status.h>
33 #include <linux/obd_ptlbd.h>
35 static int ptlbd_cl_setup(struct obd_device *obddev, obd_count len, void *buf)
37 struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
38 struct obd_import *imp = &ptlbd->bd_import;
39 struct obd_ioctl_data* data = buf;
40 struct obd_uuid server_uuid;
43 if ( ptlbd->bd_import.imp_connection != NULL )
46 if (data->ioc_inllen1 < 1) {
47 CERROR("requires a PTLBD server UUID\n");
51 if (data->ioc_inllen1 > 37) {
52 CERROR("PTLBD server UUID must be less than 38 characters\n");
56 obd_str2uuid(&server_uuid, data->ioc_inlbuf1);
58 imp->imp_connection = ptlrpc_uuid_to_connection(&server_uuid);
59 if (!imp->imp_connection)
62 INIT_LIST_HEAD(&imp->imp_replay_list);
63 INIT_LIST_HEAD(&imp->imp_sending_list);
64 INIT_LIST_HEAD(&imp->imp_delayed_list);
65 spin_lock_init(&imp->imp_lock);
67 * from client_obd_connect.. *shrug*
69 INIT_LIST_HEAD(&imp->imp_chain);
70 imp->imp_last_xid = 0;
71 imp->imp_max_transno = 0;
72 imp->imp_peer_committed_transno = 0;
73 imp->imp_level = LUSTRE_CONN_FULL;
75 ptlrpc_init_client(PTLBD_REQUEST_PORTAL, PTLBD_REPLY_PORTAL,
76 "ptlbd", &ptlbd->bd_client);
77 imp->imp_client = &ptlbd->bd_client;
78 imp->imp_obd = obddev;
80 ptlbd_blk_register(ptlbd);
85 static int ptlbd_cl_cleanup(struct obd_device *obddev)
87 // struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
90 CERROR("I should be cleaning things up\n");
96 static int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
97 struct obd_uuid cluuid, struct recovd_obd *recovd,
98 ptlrpc_recovery_cb_t recover)
100 struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
101 struct obd_import *imp = &ptlbd->bd_import;
105 rc = class_connect(conn, obd, cluuid);
109 INIT_LIST_HEAD(&imp->imp_chain);
110 imp->imp_last_xid = 0;
111 imp->imp_max_transno = 0;
112 imp->imp_peer_last_xid = 0;
113 imp->imp_peer_committed_transno = 0;
114 imp->imp_level = LUSTRE_CONN_FULL;
120 static struct obd_ops ptlbd_cl_obd_ops = {
121 o_owner: THIS_MODULE,
122 o_setup: ptlbd_cl_setup,
123 o_cleanup: ptlbd_cl_cleanup,
125 o_connect: ptlbd_cl_connect,
126 o_disconnect: class_disconnect
130 int ptlbd_cl_init(void)
132 struct lprocfs_static_vars lvars;
134 lprocfs_init_vars(&lvars);
135 return class_register_type(&ptlbd_cl_obd_ops, lvars.module_vars,
136 OBD_PTLBD_CL_DEVICENAME);
139 void ptlbd_cl_exit(void)
141 class_unregister_type(OBD_PTLBD_CL_DEVICENAME);