Whamcloud - gitweb
df72d83b9fad3bbabe0ad7211c1fd8b39b7d7b43
[fs/lustre-release.git] / lustre / ptlrpc / rpc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22
23 #define EXPORT_SYMTAB
24 #define DEBUG_SUBSYSTEM S_RPC
25
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>
32
33 extern int ptlrpc_init_portals(void);
34 extern void ptlrpc_exit_portals(void);
35
36 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
37 {
38         struct recovd_obd *recovd = &obddev->u.recovd;
39         int err;
40         ENTRY;
41
42         MOD_INC_USE_COUNT;
43         memset(recovd, 0, sizeof(*recovd));
44
45         err = recovd_setup(recovd);
46         if (err) {
47                 MOD_DEC_USE_COUNT;
48                 RETURN(err);
49         }
50
51         RETURN(0);
52 }
53
54 int connmgr_cleanup(struct obd_device *dev)
55 {
56         struct recovd_obd *recovd = &dev->u.recovd;
57         int err;
58
59         err = recovd_cleanup(recovd);
60         if (err)
61                 LBUG();
62
63         MOD_DEC_USE_COUNT;
64         RETURN(0);
65 }
66
67
68 int connmgr_iocontrol(long cmd, struct lustre_handle *conn, int len, void *karg,
69                       void *uarg)
70 {
71         struct obd_device *obd = class_conn2obd(conn);
72         struct recovd_obd *recovd = &obd->u.recovd;
73
74         ENTRY;
75         if (cmd == OBD_IOC_RECOVD_NEWCONN) { 
76                 spin_lock(&recovd->recovd_lock);
77                 recovd->recovd_flags |= RECOVD_UPCALL_ANSWER;
78                 recovd->recovd_wakeup_flag = 1;
79                 wake_up(&recovd->recovd_waitq);
80                 spin_unlock(&recovd->recovd_lock);
81                 EXIT;
82         }
83         return 0;
84 }
85
86
87 /* use obd ops to offer management infrastructure */
88 static struct obd_ops recovd_obd_ops = {
89         o_setup:       connmgr_setup,
90         o_cleanup:     connmgr_cleanup,
91         o_iocontrol:   connmgr_iocontrol,
92 };
93
94 static int __init ptlrpc_init(void)
95 {
96         int rc; 
97         rc = ptlrpc_init_portals();
98         if (rc) 
99                 RETURN(rc);
100         ptlrpc_init_connection();
101         class_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
102         return 0;
103 }
104
105 static void __exit ptlrpc_exit(void)
106 {
107         class_unregister_type(LUSTRE_HA_NAME);
108         ptlrpc_exit_portals();
109         ptlrpc_cleanup_connection();
110 }
111
112 /* connmgr.c */
113 EXPORT_SYMBOL(recovd_conn_fail);
114 EXPORT_SYMBOL(recovd_conn_manage);
115 EXPORT_SYMBOL(recovd_conn_fixed);
116 EXPORT_SYMBOL(recovd_setup);
117 EXPORT_SYMBOL(recovd_cleanup);
118
119 /* connection.c */
120 EXPORT_SYMBOL(ptlrpc_readdress_connection);
121 EXPORT_SYMBOL(ptlrpc_get_connection);
122 EXPORT_SYMBOL(ptlrpc_put_connection);
123 EXPORT_SYMBOL(ptlrpc_connection_addref);
124 EXPORT_SYMBOL(ptlrpc_init_connection);
125 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
126
127 /* niobuf.c */
128 EXPORT_SYMBOL(ptlrpc_send_bulk);
129 EXPORT_SYMBOL(ptlrpc_register_bulk);
130 EXPORT_SYMBOL(ptlrpc_abort_bulk);
131 EXPORT_SYMBOL(ptlrpc_reply);
132 EXPORT_SYMBOL(ptlrpc_error);
133 EXPORT_SYMBOL(ptlrpc_resend_req);
134 EXPORT_SYMBOL(ptl_send_rpc);
135 EXPORT_SYMBOL(ptlrpc_link_svc_me);
136
137 /* client.c */
138 EXPORT_SYMBOL(ptlrpc_init_client);
139 EXPORT_SYMBOL(ptlrpc_cleanup_client);
140 EXPORT_SYMBOL(ptlrpc_req_to_uuid);
141 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
142 EXPORT_SYMBOL(ptlrpc_queue_wait);
143 EXPORT_SYMBOL(ptlrpc_continue_req);
144 EXPORT_SYMBOL(ptlrpc_replay_req);
145 EXPORT_SYMBOL(ptlrpc_restart_req);
146 EXPORT_SYMBOL(ptlrpc_prep_req);
147 EXPORT_SYMBOL(ptlrpc_free_req);
148 EXPORT_SYMBOL(ptlrpc_prep_req2);
149 EXPORT_SYMBOL(ptlrpc_req_finished);
150 EXPORT_SYMBOL(ptlrpc_prep_bulk);
151 EXPORT_SYMBOL(ptlrpc_free_bulk);
152 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
153 EXPORT_SYMBOL(ptlrpc_free_bulk_page);
154 EXPORT_SYMBOL(ptlrpc_check_status);
155
156 /* service.c */
157 EXPORT_SYMBOL(ptlrpc_init_svc);
158 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
159 EXPORT_SYMBOL(ptlrpc_start_thread);
160 EXPORT_SYMBOL(ptlrpc_unregister_service);
161
162 /* pack_generic.c */
163 EXPORT_SYMBOL(lustre_pack_msg);
164 EXPORT_SYMBOL(lustre_msg_size);
165 EXPORT_SYMBOL(lustre_unpack_msg);
166 EXPORT_SYMBOL(lustre_msg_buf);
167
168 MODULE_AUTHOR("Cluster File Systems, Inc <info@clusterfs.com>");
169 MODULE_DESCRIPTION("Lustre Request Processor v1.0");
170 MODULE_LICENSE("GPL");
171
172 module_init(ptlrpc_init);
173 module_exit(ptlrpc_exit);