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