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