Whamcloud - gitweb
b=21411 Avoid infinite loop when bulk IO delayed.
[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  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
50 #include "ptlrpc_internal.h"
51
52 cfs_mem_cache_t *ptlrpc_cbdata_slab;
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
59 __init int ptlrpc_init(void)
60 {
61         int rc, cleanup_phase = 0;
62         ENTRY;
63
64         lustre_assert_wire_constants();
65         spin_lock_init(&ptlrpc_rs_debug_lock);
66         spin_lock_init(&ptlrpc_all_services_lock);
67         init_mutex(&pinger_sem);
68         init_mutex(&ptlrpcd_sem);
69         ptlrpc_init_xid();
70
71         rc = ptlrpc_init_portals();
72         if (rc)
73                 RETURN(rc);
74         cleanup_phase = 1;
75
76         rc = ptlrpc_connection_init();
77         if (rc)
78                 GOTO(cleanup, rc);
79         cleanup_phase = 2;
80
81         ptlrpc_put_connection_superhack = ptlrpc_connection_put;
82
83         rc = ptlrpc_start_pinger();
84         if (rc)
85                 GOTO(cleanup, rc);
86         cleanup_phase = 3;
87
88         rc = ldlm_init();
89         if (rc)
90                 GOTO(cleanup, rc);
91         cleanup_phase = 4;
92
93         ptlrpc_cbdata_slab = cfs_mem_cache_create("ptlrpc_cbdatas",
94                                 sizeof (struct ptlrpc_set_cbdata), 0, 
95                                 SLAB_HWCACHE_ALIGN);
96         if (ptlrpc_cbdata_slab == NULL)
97                 GOTO(cleanup, rc);
98
99         cleanup_phase = 5;
100         rc = llog_recov_init();
101         if (rc)
102                 GOTO(cleanup, rc);
103
104         RETURN(0);
105
106 cleanup:
107         switch(cleanup_phase) {
108         case 5:
109                 cfs_mem_cache_destroy(ptlrpc_cbdata_slab);
110         case 4:
111                 ldlm_exit();
112         case 3:
113                 ptlrpc_stop_pinger();
114         case 2:
115                 ptlrpc_connection_fini();
116         case 1:
117                 ptlrpc_exit_portals();
118         default: ;
119         }
120
121         return rc;
122 }
123
124 #ifdef __KERNEL__
125 static void __exit ptlrpc_exit(void)
126 {
127         llog_recov_fini();
128         ldlm_exit();
129         ptlrpc_stop_pinger();
130         ptlrpc_exit_portals();
131         ptlrpc_connection_fini();
132         cfs_mem_cache_destroy(ptlrpc_cbdata_slab);
133 }
134
135 /* connection.c */
136 EXPORT_SYMBOL(ptlrpc_connection_get);
137 EXPORT_SYMBOL(ptlrpc_connection_put);
138 EXPORT_SYMBOL(ptlrpc_connection_addref);
139 EXPORT_SYMBOL(ptlrpc_connection_init);
140 EXPORT_SYMBOL(ptlrpc_connection_fini);
141
142 /* niobuf.c */
143 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
144 EXPORT_SYMBOL(ptlrpc_abort_bulk);
145 EXPORT_SYMBOL(ptlrpc_register_bulk);
146 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
147 EXPORT_SYMBOL(ptlrpc_send_reply);
148 EXPORT_SYMBOL(ptlrpc_reply);
149 EXPORT_SYMBOL(ptlrpc_send_error);
150 EXPORT_SYMBOL(ptlrpc_error);
151 EXPORT_SYMBOL(ptlrpc_resend_req);
152 EXPORT_SYMBOL(ptl_send_rpc);
153
154 /* client.c */
155 EXPORT_SYMBOL(ptlrpc_init_client);
156 EXPORT_SYMBOL(ptlrpc_cleanup_client);
157 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
158 EXPORT_SYMBOL(ptlrpc_queue_wait);
159 EXPORT_SYMBOL(ptlrpc_replay_req);
160 EXPORT_SYMBOL(ptlrpc_restart_req);
161 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
162 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
163 EXPORT_SYMBOL(ptlrpc_free_rq_pool);
164 EXPORT_SYMBOL(ptlrpc_prep_req_pool);
165 EXPORT_SYMBOL(ptlrpc_prep_fakereq);
166 EXPORT_SYMBOL(ptlrpc_fakereq_finished);
167 EXPORT_SYMBOL(ptlrpc_at_set_req_timeout);
168 EXPORT_SYMBOL(ptlrpc_prep_req);
169 EXPORT_SYMBOL(ptlrpc_unregister_reply);
170 EXPORT_SYMBOL(ptlrpc_req_finished);
171 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
172 EXPORT_SYMBOL(ptlrpc_request_addref);
173 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
174 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
175 EXPORT_SYMBOL(ptlrpc_free_bulk);
176 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
177 EXPORT_SYMBOL(ptlrpc_abort_inflight);
178 EXPORT_SYMBOL(ptlrpc_cleanup_imp);
179 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
180 EXPORT_SYMBOL(ptlrpc_next_xid);
181
182 EXPORT_SYMBOL(ptlrpc_prep_set);
183 EXPORT_SYMBOL(ptlrpc_set_add_cb);
184 EXPORT_SYMBOL(ptlrpc_set_add_req);
185 EXPORT_SYMBOL(ptlrpc_set_add_new_req);
186 EXPORT_SYMBOL(ptlrpc_set_destroy);
187 EXPORT_SYMBOL(ptlrpc_set_next_timeout);
188 EXPORT_SYMBOL(ptlrpc_check_set);
189 EXPORT_SYMBOL(ptlrpc_set_wait);
190 EXPORT_SYMBOL(ptlrpc_expired_set);
191 EXPORT_SYMBOL(ptlrpc_interrupted_set);
192 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
193
194 /* service.c */
195 EXPORT_SYMBOL(ptlrpc_save_lock);
196 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
197 EXPORT_SYMBOL(ptlrpc_commit_replies);
198 EXPORT_SYMBOL(ptlrpc_init_svc);
199 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
200 EXPORT_SYMBOL(ptlrpc_start_threads);
201 EXPORT_SYMBOL(ptlrpc_start_thread);
202 EXPORT_SYMBOL(ptlrpc_unregister_service);
203 EXPORT_SYMBOL(ptlrpc_service_health_check);
204 EXPORT_SYMBOL(ptlrpc_hpreq_reorder);
205
206 /* pack_generic.c */
207 EXPORT_SYMBOL(lustre_msg_check_version);
208 EXPORT_SYMBOL(lustre_pack_request);
209 EXPORT_SYMBOL(lustre_pack_reply);
210 EXPORT_SYMBOL(lustre_pack_reply_flags);
211 EXPORT_SYMBOL(lustre_shrink_reply);
212 EXPORT_SYMBOL(lustre_free_reply_state);
213 EXPORT_SYMBOL(lustre_msg_size);
214 EXPORT_SYMBOL(lustre_packed_msg_size);
215 EXPORT_SYMBOL(lustre_unpack_msg);
216 EXPORT_SYMBOL(lustre_msg_buf);
217 EXPORT_SYMBOL(lustre_msg_string);
218 EXPORT_SYMBOL(lustre_swab_reqbuf);
219 EXPORT_SYMBOL(lustre_swab_repbuf);
220 EXPORT_SYMBOL(lustre_swab_obdo);
221 EXPORT_SYMBOL(lustre_swab_obd_statfs);
222 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
223 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
224 EXPORT_SYMBOL(lustre_swab_ost_body);
225 EXPORT_SYMBOL(lustre_swab_ost_last_id);
226 EXPORT_SYMBOL(lustre_swab_ost_lvb);
227 EXPORT_SYMBOL(lustre_swab_mds_status_req);
228 EXPORT_SYMBOL(lustre_swab_mds_body);
229 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
230 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
231 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
232 EXPORT_SYMBOL(lustre_swab_mds_rec_join);
233 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
234 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
235 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
236 EXPORT_SYMBOL(lustre_swab_lov_desc);
237 EXPORT_SYMBOL(lustre_swab_lov_user_md);
238 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
239 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
240 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
241 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
242 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
243 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
244 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
245 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
246 EXPORT_SYMBOL(lustre_swab_ldlm_request);
247 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
248 EXPORT_SYMBOL(lustre_swab_qdata);
249 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
250 EXPORT_SYMBOL(lustre_swab_qdata_old2);
251 #else
252 #warning "remove quota code above for format absolete in new release"
253 #endif
254 EXPORT_SYMBOL(lustre_swab_quota_adjust_qunit);
255 EXPORT_SYMBOL(lustre_msg_get_flags);
256 EXPORT_SYMBOL(lustre_msg_add_flags);
257 EXPORT_SYMBOL(lustre_msg_set_flags);
258 EXPORT_SYMBOL(lustre_msg_clear_flags);
259 EXPORT_SYMBOL(lustre_msg_get_op_flags);
260 EXPORT_SYMBOL(lustre_msg_add_op_flags);
261 EXPORT_SYMBOL(lustre_msg_set_op_flags);
262 EXPORT_SYMBOL(lustre_msg_get_handle );
263 EXPORT_SYMBOL(lustre_msg_get_type);
264 EXPORT_SYMBOL(lustre_msg_get_version);
265 EXPORT_SYMBOL(lustre_msg_add_version);
266 EXPORT_SYMBOL(lustre_msg_get_opc);
267 EXPORT_SYMBOL(lustre_msg_get_last_xid);
268 EXPORT_SYMBOL(lustre_msg_get_last_committed);
269 EXPORT_SYMBOL(lustre_msg_get_versions);
270 EXPORT_SYMBOL(lustre_msg_get_transno);
271 EXPORT_SYMBOL(lustre_msg_get_status);
272 EXPORT_SYMBOL(lustre_msg_get_slv);
273 EXPORT_SYMBOL(lustre_msg_get_limit);
274 EXPORT_SYMBOL(lustre_msg_set_slv);
275 EXPORT_SYMBOL(lustre_msg_set_limit);
276 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
277 EXPORT_SYMBOL(lustre_msg_is_v1);
278 EXPORT_SYMBOL(lustre_msg_get_magic);
279 EXPORT_SYMBOL(lustre_msg_set_handle);
280 EXPORT_SYMBOL(lustre_msg_set_type);
281 EXPORT_SYMBOL(lustre_msg_set_opc);
282 EXPORT_SYMBOL(lustre_msg_set_last_xid);
283 EXPORT_SYMBOL(lustre_msg_set_last_committed);
284 EXPORT_SYMBOL(lustre_msg_set_versions);
285 EXPORT_SYMBOL(lustre_msg_set_transno);
286 EXPORT_SYMBOL(lustre_msg_set_status);
287 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
288 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
289 EXPORT_SYMBOL(lustre_swab_fiemap);
290
291 /* recover.c */
292 EXPORT_SYMBOL(ptlrpc_disconnect_import);
293 EXPORT_SYMBOL(ptlrpc_resend);
294 EXPORT_SYMBOL(ptlrpc_wake_delayed);
295 EXPORT_SYMBOL(ptlrpc_set_import_active);
296 EXPORT_SYMBOL(ptlrpc_activate_import);
297 EXPORT_SYMBOL(ptlrpc_deactivate_import);
298 EXPORT_SYMBOL(ptlrpc_invalidate_import);
299 EXPORT_SYMBOL(ptlrpc_fail_import);
300 EXPORT_SYMBOL(ptlrpc_recover_import);
301 EXPORT_SYMBOL(ptlrpc_import_setasync);
302
303 /* pinger.c */
304 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
305 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
306 EXPORT_SYMBOL(ptlrpc_add_timeout_client);
307 EXPORT_SYMBOL(ptlrpc_del_timeout_client);
308 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
309
310 /* ptlrpcd.c */
311 EXPORT_SYMBOL(ptlrpcd_addref);
312 EXPORT_SYMBOL(ptlrpcd_decref);
313 EXPORT_SYMBOL(ptlrpcd_add_req);
314 EXPORT_SYMBOL(ptlrpcd_wake);
315
316 /* llogd.c */
317 EXPORT_SYMBOL(llog_origin_handle_create);
318 EXPORT_SYMBOL(llog_origin_handle_destroy);
319 EXPORT_SYMBOL(llog_origin_handle_next_block);
320 EXPORT_SYMBOL(llog_origin_handle_prev_block);
321 EXPORT_SYMBOL(llog_origin_handle_read_header);
322 EXPORT_SYMBOL(llog_origin_handle_close);
323 EXPORT_SYMBOL(llog_client_ops);
324 EXPORT_SYMBOL(llog_catinfo);
325
326 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
327 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
328 MODULE_LICENSE("GPL");
329
330 cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
331 #endif