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.
25 #include <linux/module.h>
27 #define DEBUG_SUBSYSTEM S_RPC
29 #include <linux/lustre_ha.h>
31 extern int ptlrpc_init_portals(void);
32 extern void ptlrpc_exit_portals(void);
34 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
36 struct recovd_obd *recovd = &obddev->u.recovd;
40 memset(recovd, 0, sizeof(*recovd));
42 OBD_ALLOC(recovd->recovd_client, sizeof(*recovd->recovd_client));
46 err = recovd_setup(recovd);
50 recovd->recovd_service =
51 ptlrpc_init_svc(128 * 1024,CONNMGR_REQUEST_PORTAL,
52 CONNMGR_REPLY_PORTAL, "self", connmgr_handle);
53 if (!recovd->recovd_service) {
54 CERROR("failed to start service\n");
55 GOTO(err_recovd, err = -EINVAL);
58 ptlrpc_init_client(NULL, CONNMGR_REQUEST_PORTAL,
59 CONNMGR_REPLY_PORTAL, recovd->recovd_client);
61 err = ptlrpc_start_thread(obddev, recovd->recovd_service, "lustre_connmgr");
63 CERROR("cannot start thread\n");
68 ptlrpc_connmgr = recovd;
72 rpc_unregister_service(recovd->recovd_service);
74 recovd_cleanup(recovd);
76 if (recovd->recovd_client)
77 OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
81 int connmgr_cleanup(struct obd_device *dev)
83 struct recovd_obd *recovd = &dev->u.recovd;
86 err = recovd_cleanup(recovd);
90 ptlrpc_stop_thread(recovd->recovd_service);
91 rpc_unregister_service(recovd->recovd_service);
92 if (!list_empty(&recovd->recovd_service->srv_reqs)) {
93 // XXX reply with errors and clean up
94 CERROR("Request list not empty!\n");
97 OBD_FREE(recovd->recovd_service, sizeof(*recovd->recovd_service));
98 recovd->recovd_flags = MGR_STOPPING;
100 OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
105 /* use obd ops to offer management infrastructure */
106 static struct obd_ops recovd_obd_ops = {
107 o_setup: connmgr_setup,
108 o_cleanup: connmgr_cleanup,
111 static int __init ptlrpc_init(void)
114 rc = ptlrpc_init_portals();
117 ptlrpc_init_connection();
118 obd_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
122 static void __exit ptlrpc_exit(void)
124 obd_unregister_type(LUSTRE_HA_NAME);
125 ptlrpc_exit_portals();
126 ptlrpc_cleanup_connection();
129 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
130 MODULE_DESCRIPTION("Lustre Request Processor v1.0");
131 MODULE_LICENSE("GPL");
133 module_init(ptlrpc_init);
134 module_exit(ptlrpc_exit);