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