1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/version.h>
23 #include <linux/module.h>
26 #define DEBUG_SUBSYSTEM S_PTLBD
28 #include <linux/obd_support.h>
29 #include <linux/obd_class.h>
30 #include <linux/lustre_debug.h>
31 #include <linux/lprocfs_status.h>
32 #include <linux/obd_ptlbd.h>
34 static int ptlbd_cl_setup(struct obd_device *obddev, obd_count len, void *buf)
36 struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
37 struct obd_import *imp = &ptlbd->bd_import;
38 struct obd_ioctl_data* data = buf;
39 obd_uuid_t server_uuid;
42 if ( ptlbd->bd_import.imp_connection != NULL )
45 if (data->ioc_inllen1 < 1) {
46 CERROR("requires a PTLBD server UUID\n");
50 if (data->ioc_inllen1 > 37) {
51 CERROR("PTLBD server UUID must be less than 38 characters\n");
55 memcpy(server_uuid, data->ioc_inlbuf1, MIN(data->ioc_inllen1,
56 sizeof(server_uuid)));
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_last_xid = 0;
73 imp->imp_peer_committed_transno = 0;
74 imp->imp_level = LUSTRE_CONN_FULL;
76 ptlrpc_init_client(PTLBD_REQUEST_PORTAL, PTLBD_REPLY_PORTAL,
77 "ptlbd", &ptlbd->bd_client);
78 imp->imp_client = &ptlbd->bd_client;
79 imp->imp_obd = obddev;
81 ptlbd_blk_register(ptlbd);
86 static int ptlbd_cl_cleanup(struct obd_device *obddev)
88 // struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
91 CERROR("I should be cleaning things up\n");
97 static int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
98 obd_uuid_t cluuid, struct recovd_obd *recovd,
99 ptlrpc_recovery_cb_t recover)
101 struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
102 struct obd_import *imp = &ptlbd->bd_import;
106 rc = class_connect(conn, obd, cluuid);
110 INIT_LIST_HEAD(&imp->imp_chain);
111 imp->imp_last_xid = 0;
112 imp->imp_max_transno = 0;
113 imp->imp_peer_last_xid = 0;
114 imp->imp_peer_committed_transno = 0;
115 imp->imp_level = LUSTRE_CONN_FULL;
121 static struct obd_ops ptlbd_cl_obd_ops = {
122 o_owner: THIS_MODULE,
123 o_setup: ptlbd_cl_setup,
124 o_cleanup: ptlbd_cl_cleanup,
126 o_connect: ptlbd_cl_connect,
127 o_disconnect: class_disconnect
131 int ptlbd_cl_init(void)
133 extern struct lprocfs_vars status_class_var[];
135 return class_register_type(&ptlbd_cl_obd_ops, status_class_var,
136 OBD_PTLBD_CL_DEVICENAME);
139 void ptlbd_cl_exit(void)
141 class_unregister_type(OBD_PTLBD_CL_DEVICENAME);