Whamcloud - gitweb
94e3df4e38b46a19710ea37c889673a806e00c3a
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see [sun.com URL with a
20  * copy of GPLv2].
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef EXPORT_SYMTAB
38 # define EXPORT_SYMTAB
39 #endif
40 #define DEBUG_SUBSYSTEM S_RPC
41
42 #ifndef __KERNEL__
43 # include <liblustre.h>
44 #endif
45
46 #include <obd_support.h>
47 #include <obd_class.h>
48 #include <lustre_net.h>
49 #include <lustre_req_layout.h>
50
51 #include "ptlrpc_internal.h"
52
53 extern spinlock_t ptlrpc_last_xid_lock;
54 extern spinlock_t ptlrpc_rs_debug_lock;
55 extern spinlock_t ptlrpc_all_services_lock;
56 extern struct semaphore pinger_sem;
57 extern struct semaphore ptlrpcd_sem;
58 extern int ptlrpc_init_portals(void);
59 extern void ptlrpc_exit_portals(void);
60
61 __init int ptlrpc_init(void)
62 {
63         int rc, cleanup_phase = 0;
64         ENTRY;
65
66         lustre_assert_wire_constants();
67         spin_lock_init(&ptlrpc_last_xid_lock);
68         spin_lock_init(&ptlrpc_rs_debug_lock);
69         spin_lock_init(&ptlrpc_all_services_lock);
70         init_mutex(&pinger_sem);
71         init_mutex(&ptlrpcd_sem);
72
73         rc = req_layout_init();
74         if (rc)
75                 RETURN(rc);
76         cleanup_phase = 1;
77
78         rc = ptlrpc_init_portals();
79         if (rc)
80                 RETURN(rc);
81         cleanup_phase = 2;
82
83         rc = ptlrpc_init_connection();
84         if (rc)
85                 GOTO(cleanup, rc);
86         cleanup_phase = 3;
87
88         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
89
90         rc = ptlrpc_start_pinger();
91         if (rc)
92                 GOTO(cleanup, rc);
93         cleanup_phase = 4;
94
95         rc = ldlm_init();
96         if (rc)
97                 GOTO(cleanup, rc);
98         cleanup_phase = 5;
99
100         rc = sptlrpc_init();
101         if (rc)
102                 GOTO(cleanup, rc);
103
104         RETURN(0);
105
106 cleanup:
107         switch(cleanup_phase) {
108         case 5:
109                 ldlm_exit();
110         case 4:
111                 ptlrpc_stop_pinger();
112         case 3:
113                 ptlrpc_cleanup_connection();
114         case 2:
115                 ptlrpc_exit_portals();
116         case 1:
117                 req_layout_fini();
118         default: ;
119         }
120
121         return rc;
122 }
123
124 #ifdef __KERNEL__
125 static void __exit ptlrpc_exit(void)
126 {
127         sptlrpc_fini();
128         ldlm_exit();
129         ptlrpc_stop_pinger();
130         ptlrpc_exit_portals();
131         ptlrpc_cleanup_connection();
132 }
133
134 /* connection.c */
135 EXPORT_SYMBOL(ptlrpc_dump_connections);
136 EXPORT_SYMBOL(ptlrpc_readdress_connection);
137 EXPORT_SYMBOL(ptlrpc_get_connection);
138 EXPORT_SYMBOL(ptlrpc_put_connection);
139 EXPORT_SYMBOL(ptlrpc_connection_addref);
140 EXPORT_SYMBOL(ptlrpc_init_connection);
141 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
142
143 /* niobuf.c */
144 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
145 EXPORT_SYMBOL(ptlrpc_abort_bulk);
146 EXPORT_SYMBOL(ptlrpc_register_bulk);
147 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
148 EXPORT_SYMBOL(ptlrpc_send_reply);
149 EXPORT_SYMBOL(ptlrpc_reply);
150 EXPORT_SYMBOL(ptlrpc_send_error);
151 EXPORT_SYMBOL(ptlrpc_error);
152 EXPORT_SYMBOL(ptlrpc_resend_req);
153 EXPORT_SYMBOL(ptl_send_rpc);
154
155 /* client.c */
156 EXPORT_SYMBOL(ptlrpc_init_client);
157 EXPORT_SYMBOL(ptlrpc_cleanup_client);
158 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
159 EXPORT_SYMBOL(ptlrpc_queue_wait);
160 EXPORT_SYMBOL(ptlrpc_replay_req);
161 EXPORT_SYMBOL(ptlrpc_restart_req);
162 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
163 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
164 EXPORT_SYMBOL(ptlrpc_free_rq_pool);
165 EXPORT_SYMBOL(ptlrpc_prep_req_pool);
166 EXPORT_SYMBOL(ptlrpc_at_set_req_timeout);
167 EXPORT_SYMBOL(ptlrpc_request_alloc);
168 EXPORT_SYMBOL(ptlrpc_request_alloc_pool);
169 EXPORT_SYMBOL(ptlrpc_request_free);
170 EXPORT_SYMBOL(ptlrpc_request_pack);
171 EXPORT_SYMBOL(ptlrpc_request_alloc_pack);
172 EXPORT_SYMBOL(ptlrpc_prep_req);
173 EXPORT_SYMBOL(ptlrpc_free_req);
174 EXPORT_SYMBOL(ptlrpc_unregister_reply);
175 EXPORT_SYMBOL(ptlrpc_req_finished);
176 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
177 EXPORT_SYMBOL(ptlrpc_request_addref);
178 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
179 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
180 EXPORT_SYMBOL(ptlrpc_free_bulk);
181 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
182 EXPORT_SYMBOL(ptlrpc_abort_inflight);
183 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
184 EXPORT_SYMBOL(ptlrpc_next_xid);
185 EXPORT_SYMBOL(ptlrpc_req_set_repsize);
186 EXPORT_SYMBOL(ptlrpc_request_set_replen);
187
188 EXPORT_SYMBOL(ptlrpc_prep_set);
189 EXPORT_SYMBOL(ptlrpc_set_add_cb);
190 EXPORT_SYMBOL(ptlrpc_set_add_req);
191 EXPORT_SYMBOL(ptlrpc_set_add_new_req);
192 EXPORT_SYMBOL(ptlrpc_set_destroy);
193 EXPORT_SYMBOL(ptlrpc_set_next_timeout);
194 EXPORT_SYMBOL(ptlrpc_check_set);
195 EXPORT_SYMBOL(ptlrpc_set_wait);
196 EXPORT_SYMBOL(ptlrpc_expired_set);
197 EXPORT_SYMBOL(ptlrpc_interrupted_set);
198 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
199
200 /* service.c */
201 EXPORT_SYMBOL(ptlrpc_save_lock);
202 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
203 EXPORT_SYMBOL(ptlrpc_commit_replies);
204 EXPORT_SYMBOL(ptlrpc_init_svc);
205 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
206 EXPORT_SYMBOL(ptlrpc_start_threads);
207 EXPORT_SYMBOL(ptlrpc_start_thread);
208 EXPORT_SYMBOL(ptlrpc_unregister_service);
209 EXPORT_SYMBOL(ptlrpc_daemonize);
210 EXPORT_SYMBOL(ptlrpc_service_health_check);
211
212 /* pack_generic.c */
213 EXPORT_SYMBOL(lustre_msg_swabbed);
214 EXPORT_SYMBOL(lustre_msg_check_version);
215 EXPORT_SYMBOL(lustre_pack_request);
216 EXPORT_SYMBOL(lustre_pack_reply);
217 EXPORT_SYMBOL(lustre_pack_reply_flags);
218 EXPORT_SYMBOL(lustre_shrink_msg);
219 EXPORT_SYMBOL(lustre_free_reply_state);
220 EXPORT_SYMBOL(lustre_msg_size);
221 EXPORT_SYMBOL(lustre_packed_msg_size);
222 EXPORT_SYMBOL(lustre_unpack_msg);
223 EXPORT_SYMBOL(lustre_msg_buf);
224 EXPORT_SYMBOL(lustre_msg_string);
225 EXPORT_SYMBOL(lustre_swab_ptlrpc_body);
226 EXPORT_SYMBOL(lustre_swab_buf);
227 EXPORT_SYMBOL(lustre_swab_reqbuf);
228 EXPORT_SYMBOL(lustre_swab_repbuf);
229 EXPORT_SYMBOL(lustre_swab_obdo);
230 EXPORT_SYMBOL(lustre_swab_obd_statfs);
231 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
232 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
233 EXPORT_SYMBOL(lustre_swab_ost_body);
234 EXPORT_SYMBOL(lustre_swab_ost_last_id);
235 EXPORT_SYMBOL(lustre_swab_ost_lvb);
236 EXPORT_SYMBOL(lustre_swab_mds_status_req);
237 EXPORT_SYMBOL(lustre_swab_mds_body);
238 EXPORT_SYMBOL(lustre_swab_mdt_body);
239 EXPORT_SYMBOL(lustre_swab_mdt_epoch);
240 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
241 EXPORT_SYMBOL(lustre_swab_mds_remote_perm);
242 EXPORT_SYMBOL(lustre_swab_mdt_remote_perm);
243 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
244 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
245 EXPORT_SYMBOL(lustre_swab_mds_rec_join);
246 EXPORT_SYMBOL(lustre_swab_mdt_rec_join);
247 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
248 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
249 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
250 EXPORT_SYMBOL(lustre_swab_mdt_rec_reint);
251 EXPORT_SYMBOL(lustre_swab_lov_desc);
252 EXPORT_SYMBOL(lustre_swab_lov_user_md);
253 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
254 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
255 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
256 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
257 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
258 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
259 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
260 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
261 EXPORT_SYMBOL(lustre_swab_ldlm_request);
262 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
263 EXPORT_SYMBOL(lustre_swab_qdata);
264 EXPORT_SYMBOL(lustre_swab_qdata_old);
265 EXPORT_SYMBOL(lustre_msg_get_flags);
266 EXPORT_SYMBOL(lustre_msg_add_flags);
267 EXPORT_SYMBOL(lustre_msg_set_flags);
268 EXPORT_SYMBOL(lustre_msg_clear_flags);
269 EXPORT_SYMBOL(lustre_msg_get_op_flags);
270 EXPORT_SYMBOL(lustre_msg_add_op_flags);
271 EXPORT_SYMBOL(lustre_msg_set_op_flags);
272 EXPORT_SYMBOL(lustre_msg_get_handle );
273 EXPORT_SYMBOL(lustre_msg_get_type);
274 EXPORT_SYMBOL(lustre_msg_get_version);
275 EXPORT_SYMBOL(lustre_msg_add_version);
276 EXPORT_SYMBOL(lustre_msg_get_opc);
277 EXPORT_SYMBOL(lustre_msg_get_last_xid);
278 EXPORT_SYMBOL(lustre_msg_get_last_committed);
279 EXPORT_SYMBOL(lustre_msg_get_transno);
280 EXPORT_SYMBOL(lustre_msg_get_status);
281 EXPORT_SYMBOL(lustre_msg_get_slv);
282 EXPORT_SYMBOL(lustre_msg_get_limit);
283 EXPORT_SYMBOL(lustre_msg_set_slv);
284 EXPORT_SYMBOL(lustre_msg_set_limit);
285 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
286 EXPORT_SYMBOL(lustre_msg_is_v1);
287 EXPORT_SYMBOL(lustre_msg_get_magic);
288 EXPORT_SYMBOL(lustre_msg_set_handle);
289 EXPORT_SYMBOL(lustre_msg_set_type);
290 EXPORT_SYMBOL(lustre_msg_set_opc);
291 EXPORT_SYMBOL(lustre_msg_set_last_xid);
292 EXPORT_SYMBOL(lustre_msg_set_last_committed);
293 EXPORT_SYMBOL(lustre_msg_set_transno);
294 EXPORT_SYMBOL(lustre_msg_set_status);
295 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
296 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
297 EXPORT_SYMBOL(lustre_swab_md_fld);
298 EXPORT_SYMBOL(lustre_swab_generic_32s);
299 EXPORT_SYMBOL(lustre_swab_lustre_capa);
300 EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
301
302 /* recover.c */
303 EXPORT_SYMBOL(ptlrpc_disconnect_import);
304 EXPORT_SYMBOL(ptlrpc_resend);
305 EXPORT_SYMBOL(ptlrpc_wake_delayed);
306 EXPORT_SYMBOL(ptlrpc_set_import_active);
307 EXPORT_SYMBOL(ptlrpc_activate_import);
308 EXPORT_SYMBOL(ptlrpc_deactivate_import);
309 EXPORT_SYMBOL(ptlrpc_invalidate_import);
310 EXPORT_SYMBOL(ptlrpc_fail_import);
311 EXPORT_SYMBOL(ptlrpc_recover_import);
312
313 /* pinger.c */
314 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
315 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
316 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
317
318 /* ptlrpcd.c */
319 EXPORT_SYMBOL(ptlrpcd_addref);
320 EXPORT_SYMBOL(ptlrpcd_decref);
321 EXPORT_SYMBOL(ptlrpcd_add_req);
322 EXPORT_SYMBOL(ptlrpcd_wake);
323
324 /* llogd.c */
325 EXPORT_SYMBOL(llog_origin_handle_create);
326 EXPORT_SYMBOL(llog_origin_handle_destroy);
327 EXPORT_SYMBOL(llog_origin_handle_next_block);
328 EXPORT_SYMBOL(llog_origin_handle_prev_block);
329 EXPORT_SYMBOL(llog_origin_handle_read_header);
330 EXPORT_SYMBOL(llog_origin_handle_close);
331 EXPORT_SYMBOL(llog_client_ops);
332 EXPORT_SYMBOL(llog_catinfo);
333
334 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
335 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
336 MODULE_LICENSE("GPL");
337
338 cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
339 #endif