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.
24 #define DEBUG_SUBSYSTEM S_RPC
26 #include <linux/module.h>
27 #include <linux/obd_support.h>
28 #include <linux/obd_class.h>
29 #include <linux/lustre_lib.h>
30 #include <linux/lustre_ha.h>
31 #include <linux/init.h>
33 extern int ptlrpc_init_portals(void);
34 extern void ptlrpc_exit_portals(void);
36 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
38 struct recovd_obd *recovd = &obddev->u.recovd;
43 memset(recovd, 0, sizeof(*recovd));
45 err = recovd_setup(recovd);
54 int connmgr_cleanup(struct obd_device *dev)
56 struct recovd_obd *recovd = &dev->u.recovd;
59 err = recovd_cleanup(recovd);
67 /* should this be in llite? */
69 int connmgr_iocontrol(long cmd, struct lustre_handle *hdl, int len, void *karg,
72 struct ptlrpc_connection *conn = NULL;
73 struct obd_device *obd = class_conn2obd(hdl);
74 struct recovd_obd *recovd = &obd->u.recovd;
75 struct obd_ioctl_data *data = karg;
76 #if 0 && PARALLEL_RECOVERY
77 struct list_head *tmp;
82 if (cmd != OBD_IOC_RECOVD_NEWCONN)
85 /* Find the connection that's been rebuilt. */
86 spin_lock(&recovd->recovd_lock);
87 #if 0 && PARALLEL_RECOVERY
88 list_for_each(tmp, &recovd->recovd_troubled_items) {
89 conn = list_entry(tmp, struct ptlrpc_connection,
90 c_recovd_data.rd_managed_chain);
92 LASSERT(conn->c_recovd_data.rd_recovd == recovd); /* sanity */
94 if (!strcmp(conn->c_remote_uuid, data->ioc_inlbuf1))
99 if (!recovd->recovd_current_rd) {
100 spin_unlock(&recovd->recovd_lock);
104 conn = class_rd2conn(recovd->recovd_current_rd);
105 spin_unlock(&recovd->recovd_lock);
107 spin_lock(&conn->c_lock);
109 if (strcmp(conn->c_remote_uuid, data->ioc_inlbuf1)) {
110 CERROR("NEWCONN for %s: currently recovering %s\n",
111 data->ioc_inlbuf1, conn->c_remote_uuid);
112 spin_unlock(&conn->c_lock);
116 if (data->ioc_inllen2) {
117 CERROR("conn %p UUID change %s -> %s\n",
118 conn, conn->c_remote_uuid, data->ioc_inlbuf2);
119 strcpy(conn->c_remote_uuid, data->ioc_inlbuf2);
121 CERROR("conn %p UUID %s reconnected\n", conn,
122 conn->c_remote_uuid);
124 ptlrpc_readdress_connection(conn, conn->c_remote_uuid);
126 spin_lock(&recovd->recovd_lock);
127 #if 0 && PARALLEL_RECOVERY
128 if (conn->c_recovd_data->rd_state != RECOVD_PREPARING)
130 conn->c_recovd_data->rd_state = RECOVD_PREPARED;
132 if (recovd->recovd_phase != RECOVD_PREPARING ||
133 recovd->recovd_next_phase != RECOVD_PREPARED ||
134 recovd->recovd_current_rd != &conn->c_recovd_data) {
137 recovd->recovd_phase = RECOVD_PREPARED;
138 wake_up(&recovd->recovd_waitq);
139 spin_unlock(&recovd->recovd_lock);
140 spin_unlock(&conn->c_lock);
145 /* use obd ops to offer management infrastructure */
146 static struct obd_ops recovd_obd_ops = {
147 o_setup: connmgr_setup,
148 o_cleanup: connmgr_cleanup,
149 o_iocontrol: connmgr_iocontrol,
150 o_connect: class_connect,
151 o_disconnect: class_disconnect
154 static int __init ptlrpc_init(void)
157 rc = ptlrpc_init_portals();
160 ptlrpc_init_connection();
161 class_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
165 static void __exit ptlrpc_exit(void)
167 class_unregister_type(LUSTRE_HA_NAME);
168 ptlrpc_exit_portals();
169 ptlrpc_cleanup_connection();
173 EXPORT_SYMBOL(ptlrpc_recovd);
174 EXPORT_SYMBOL(recovd_conn_fail);
175 EXPORT_SYMBOL(recovd_conn_manage);
176 EXPORT_SYMBOL(recovd_conn_fixed);
177 EXPORT_SYMBOL(recovd_setup);
178 EXPORT_SYMBOL(recovd_cleanup);
181 EXPORT_SYMBOL(ptlrpc_readdress_connection);
182 EXPORT_SYMBOL(ptlrpc_get_connection);
183 EXPORT_SYMBOL(ptlrpc_put_connection);
184 EXPORT_SYMBOL(ptlrpc_connection_addref);
185 EXPORT_SYMBOL(ptlrpc_init_connection);
186 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
189 EXPORT_SYMBOL(ptlrpc_send_bulk);
190 EXPORT_SYMBOL(ptlrpc_register_bulk);
191 EXPORT_SYMBOL(ptlrpc_abort_bulk);
192 EXPORT_SYMBOL(ptlrpc_reply);
193 EXPORT_SYMBOL(ptlrpc_error);
194 EXPORT_SYMBOL(ptlrpc_resend_req);
195 EXPORT_SYMBOL(ptl_send_rpc);
196 EXPORT_SYMBOL(ptlrpc_link_svc_me);
199 EXPORT_SYMBOL(ptlrpc_init_client);
200 EXPORT_SYMBOL(ptlrpc_cleanup_client);
201 EXPORT_SYMBOL(ptlrpc_req_to_uuid);
202 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
203 EXPORT_SYMBOL(ptlrpc_queue_wait);
204 EXPORT_SYMBOL(ptlrpc_continue_req);
205 EXPORT_SYMBOL(ptlrpc_replay_req);
206 EXPORT_SYMBOL(ptlrpc_restart_req);
207 EXPORT_SYMBOL(ptlrpc_prep_req);
208 EXPORT_SYMBOL(ptlrpc_free_req);
209 EXPORT_SYMBOL(ptlrpc_req_finished);
210 EXPORT_SYMBOL(ptlrpc_prep_bulk);
211 EXPORT_SYMBOL(ptlrpc_free_bulk);
212 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
213 EXPORT_SYMBOL(ptlrpc_free_bulk_page);
214 EXPORT_SYMBOL(ptlrpc_check_status);
217 EXPORT_SYMBOL(ptlrpc_init_svc);
218 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
219 EXPORT_SYMBOL(ptlrpc_start_thread);
220 EXPORT_SYMBOL(ptlrpc_unregister_service);
223 EXPORT_SYMBOL(lustre_pack_msg);
224 EXPORT_SYMBOL(lustre_msg_size);
225 EXPORT_SYMBOL(lustre_unpack_msg);
226 EXPORT_SYMBOL(lustre_msg_buf);
228 EXPORT_SYMBOL(ll_recover);
231 MODULE_AUTHOR("Cluster File Systems, Inc <info@clusterfs.com>");
232 MODULE_DESCRIPTION("Lustre Request Processor v1.0");
233 MODULE_LICENSE("GPL");
235 module_init(ptlrpc_init);
236 module_exit(ptlrpc_exit);