Whamcloud - gitweb
merge b_devel into HEAD (20030703)
[fs/lustre-release.git] / lustre / ptlrpc / ptlrpc_module.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002, 2003 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 #ifdef __KERNEL__
27 # include <linux/module.h>
28 # include <linux/init.h>
29 #else
30 # include <liblustre.h>
31 #endif
32
33 #include <linux/obd_support.h>
34 #include <linux/obd_class.h>
35 #include <linux/lustre_net.h>
36
37 #include "ptlrpc_internal.h"
38
39 extern int ptlrpc_init_portals(void);
40 extern void ptlrpc_exit_portals(void);
41 static int ldlm_hooks_referenced = 0;
42
43 int (*ptlrpc_ldlm_namespace_cleanup)(struct ldlm_namespace *, int);
44 int (*ptlrpc_ldlm_replay_locks)(struct obd_import *);
45
46 #define GET_HOOK(name)                                                         \
47 if (!ptlrpc_##name) {                                                          \
48         if (!(ptlrpc_##name = inter_module_get(#name))) {                      \
49                 CERROR("can't i_m_g(\"" #name "\")\n");                        \
50                 return 0;                                                      \
51         }                                                                      \
52 }
53
54 static int ldlm_hooks_referenced;
55
56 /* This is called from ptlrpc_get_connection, which runs after all the modules
57  * are loaded, but before anything else interesting happens.
58  */
59 int ptlrpc_get_ldlm_hooks(void)
60 {
61         if (ldlm_hooks_referenced)
62                 return 1;
63
64         GET_HOOK(ldlm_namespace_cleanup);
65         GET_HOOK(ldlm_replay_locks);
66
67         ldlm_hooks_referenced = 1;
68         RETURN(1);
69 }
70
71 #undef GET_HOOK
72
73 #define PUT_HOOK(hook)                                                         \
74 if (ptlrpc_##hook) {                                                           \
75         inter_module_put(#hook);                                               \
76         ptlrpc_##hook = NULL;                                                  \
77 }
78
79 void ptlrpc_put_ldlm_hooks(void)
80 {
81         ENTRY;
82         if (!ldlm_hooks_referenced)
83                 return;
84
85         PUT_HOOK(ldlm_namespace_cleanup);
86         PUT_HOOK(ldlm_replay_locks);
87         ldlm_hooks_referenced = 0;
88         EXIT;
89 }
90
91 #undef PUT_HOOK
92
93 int ptlrpc_ldlm_hooks_referenced(void)
94 {
95         return ldlm_hooks_referenced;
96 }
97
98 __init int ptlrpc_init(void)
99 {
100         int rc;
101         ENTRY;
102
103         lustre_assert_wire_constants ();
104         
105         rc = ptlrpc_init_portals();
106         if (rc)
107                 RETURN(rc);
108
109         ptlrpc_init_connection();
110
111         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
112         ptlrpc_abort_inflight_superhack = ptlrpc_abort_inflight;
113         RETURN(0);
114 }
115
116 static void __exit ptlrpc_exit(void)
117 {
118         ptlrpc_exit_portals();
119         ptlrpc_cleanup_connection();
120 }
121
122 /* connection.c */
123 EXPORT_SYMBOL(ptlrpc_dump_connections);
124 EXPORT_SYMBOL(ptlrpc_readdress_connection);
125 EXPORT_SYMBOL(ptlrpc_get_connection);
126 EXPORT_SYMBOL(ptlrpc_put_connection);
127 EXPORT_SYMBOL(ptlrpc_connection_addref);
128 EXPORT_SYMBOL(ptlrpc_init_connection);
129 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
130
131 /* niobuf.c */
132 EXPORT_SYMBOL(ptlrpc_bulk_put);
133 EXPORT_SYMBOL(ptlrpc_bulk_get);
134 EXPORT_SYMBOL(ptlrpc_abort_bulk);
135 EXPORT_SYMBOL(ptlrpc_register_bulk);
136 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
137 EXPORT_SYMBOL(ptlrpc_reply);
138 EXPORT_SYMBOL(ptlrpc_error);
139 EXPORT_SYMBOL(ptlrpc_resend_req);
140 EXPORT_SYMBOL(ptl_send_rpc);
141 EXPORT_SYMBOL(ptlrpc_link_svc_me);
142
143 /* client.c */
144 EXPORT_SYMBOL(ptlrpc_init_client);
145 EXPORT_SYMBOL(ptlrpc_cleanup_client);
146 EXPORT_SYMBOL(ptlrpc_req_to_uuid);
147 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
148 EXPORT_SYMBOL(ptlrpc_queue_wait);
149 EXPORT_SYMBOL(ptlrpc_replay_req);
150 EXPORT_SYMBOL(ptlrpc_restart_req);
151 EXPORT_SYMBOL(ptlrpc_prep_req);
152 EXPORT_SYMBOL(ptlrpc_free_req);
153 EXPORT_SYMBOL(ptlrpc_unregister_reply);
154 EXPORT_SYMBOL(ptlrpc_req_finished);
155 EXPORT_SYMBOL(ptlrpc_request_addref);
156 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
157 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
158 EXPORT_SYMBOL(ptlrpc_free_bulk);
159 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
160 EXPORT_SYMBOL(ptlrpc_free_bulk_page);
161 EXPORT_SYMBOL(ptlrpc_abort_inflight);
162 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
163 EXPORT_SYMBOL(ptlrpc_next_xid);
164
165 EXPORT_SYMBOL(ptlrpc_prep_set);
166 EXPORT_SYMBOL(ptlrpc_set_add_req);
167 EXPORT_SYMBOL(ptlrpc_set_destroy);
168 EXPORT_SYMBOL(ptlrpc_set_wait);
169
170 /* service.c */
171 EXPORT_SYMBOL(ptlrpc_init_svc);
172 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
173 EXPORT_SYMBOL(ptlrpc_start_thread);
174 EXPORT_SYMBOL(ptlrpc_unregister_service);
175
176 /* pack_generic.c */
177 EXPORT_SYMBOL(lustre_pack_msg);
178 EXPORT_SYMBOL(lustre_msg_size);
179 EXPORT_SYMBOL(lustre_unpack_msg);
180 EXPORT_SYMBOL(lustre_msg_buf);
181 EXPORT_SYMBOL(lustre_msg_string);
182 EXPORT_SYMBOL(lustre_swab_reqbuf);
183 EXPORT_SYMBOL(lustre_swab_repbuf);
184 EXPORT_SYMBOL(lustre_swab_obdo);
185 EXPORT_SYMBOL(lustre_swab_obd_statfs);
186 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
187 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
188 EXPORT_SYMBOL(lustre_swab_ost_body);
189 EXPORT_SYMBOL(lustre_swab_ll_fid);
190 EXPORT_SYMBOL(lustre_swab_mds_status_req);
191 EXPORT_SYMBOL(lustre_swab_mds_fileh_body);
192 EXPORT_SYMBOL(lustre_swab_mds_body);
193 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
194 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
195 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
196 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
197 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
198 EXPORT_SYMBOL(lustre_swab_lov_desc);
199 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
200 EXPORT_SYMBOL(lustre_swab_ldlm_extent);
201 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
202 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
203 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
204 EXPORT_SYMBOL(lustre_swab_ldlm_request);
205 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
206 EXPORT_SYMBOL(lustre_swab_ptlbd_op);
207 EXPORT_SYMBOL(lustre_swab_ptlbd_niob);
208 EXPORT_SYMBOL(lustre_swab_ptlbd_rsp);
209
210 /* ptlrpc_module.c */
211 EXPORT_SYMBOL(ptlrpc_put_ldlm_hooks);
212 EXPORT_SYMBOL(ptlrpc_ldlm_hooks_referenced);
213
214 /* recover.c */
215 EXPORT_SYMBOL(ptlrpc_run_recovery_over_upcall);
216 EXPORT_SYMBOL(ptlrpc_run_failed_import_upcall);
217 EXPORT_SYMBOL(ptlrpc_reconnect_import);
218 EXPORT_SYMBOL(ptlrpc_replay);
219 EXPORT_SYMBOL(ptlrpc_resend);
220 EXPORT_SYMBOL(ptlrpc_wake_delayed);
221 EXPORT_SYMBOL(ptlrpc_set_import_active);
222 EXPORT_SYMBOL(ptlrpc_fail_import);
223 EXPORT_SYMBOL(ptlrpc_fail_export);
224 EXPORT_SYMBOL(ptlrpc_recover_import);
225
226 /*ptlrpc_lib.c*/
227 EXPORT_SYMBOL(client_obd_setup);
228 EXPORT_SYMBOL(client_obd_cleanup);
229
230 /* pinger.c */
231 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
232 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
233 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
234
235 #ifdef __KERNEL__
236 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
237 MODULE_DESCRIPTION("Lustre Request Processor");
238 MODULE_LICENSE("GPL");
239
240 module_init(ptlrpc_init);
241 module_exit(ptlrpc_exit);
242 #endif