Whamcloud - gitweb
bug=13099
[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  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  *
24  */
25
26 #ifndef EXPORT_SYMTAB
27 # define EXPORT_SYMTAB
28 #endif
29 #define DEBUG_SUBSYSTEM S_RPC
30
31 #ifndef __KERNEL__
32 # include <liblustre.h>
33 #endif
34
35 #include <obd_support.h>
36 #include <obd_class.h>
37 #include <lustre_net.h>
38
39 #include "ptlrpc_internal.h"
40 cfs_mem_cache_t *ptlrpc_cbdata_slab;
41 extern spinlock_t ptlrpc_last_xid_lock;
42 extern spinlock_t ptlrpc_rs_debug_lock;
43 extern spinlock_t ptlrpc_all_services_lock;
44 extern struct semaphore pinger_sem;
45 extern struct semaphore ptlrpcd_sem;
46 extern int ptlrpc_init_portals(void);
47 extern void ptlrpc_exit_portals(void);
48
49 __init int ptlrpc_init(void)
50 {
51         int rc, cleanup_phase = 0;
52         ENTRY;
53
54         lustre_assert_wire_constants();
55         spin_lock_init(&ptlrpc_last_xid_lock);
56         spin_lock_init(&ptlrpc_rs_debug_lock);
57         spin_lock_init(&ptlrpc_all_services_lock);
58         init_mutex(&pinger_sem);
59         init_mutex(&ptlrpcd_sem);
60
61         rc = ptlrpc_init_portals();
62         if (rc)
63                 RETURN(rc);
64         cleanup_phase = 1;
65
66         rc = ptlrpc_init_connection();
67         if (rc)
68                 GOTO(cleanup, rc);
69         cleanup_phase = 2;
70
71         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
72
73         rc = ptlrpc_start_pinger();
74         if (rc)
75                 GOTO(cleanup, rc);
76         cleanup_phase = 3;
77
78         rc = ldlm_init();
79         if (rc)
80                 GOTO(cleanup, rc);
81         cleanup_phase = 4;
82
83         ptlrpc_cbdata_slab = cfs_mem_cache_create("ptlrpc_cbdatas",
84                                 sizeof (struct ptlrpc_set_cbdata), 0, 
85                                 SLAB_HWCACHE_ALIGN);
86         if (ptlrpc_cbdata_slab == NULL)
87                 GOTO(cleanup, rc);
88
89         RETURN(0);
90
91 cleanup:
92         switch(cleanup_phase) {
93         case 4:
94                 ldlm_exit();
95         case 3:
96                 ptlrpc_stop_pinger();
97         case 2:
98                 ptlrpc_cleanup_connection();
99         case 1:
100                 ptlrpc_exit_portals();
101         default: ;
102         }
103
104         return rc;
105 }
106
107 #ifdef __KERNEL__
108 static void __exit ptlrpc_exit(void)
109 {
110         ldlm_exit();
111         ptlrpc_stop_pinger();
112         ptlrpc_exit_portals();
113         ptlrpc_cleanup_connection();
114         cfs_mem_cache_destroy(ptlrpc_cbdata_slab);
115 }
116
117 /* connection.c */
118 EXPORT_SYMBOL(ptlrpc_dump_connections);
119 EXPORT_SYMBOL(ptlrpc_readdress_connection);
120 EXPORT_SYMBOL(ptlrpc_get_connection);
121 EXPORT_SYMBOL(ptlrpc_put_connection);
122 EXPORT_SYMBOL(ptlrpc_connection_addref);
123 EXPORT_SYMBOL(ptlrpc_init_connection);
124 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
125
126 /* niobuf.c */
127 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
128 EXPORT_SYMBOL(ptlrpc_abort_bulk);
129 EXPORT_SYMBOL(ptlrpc_register_bulk);
130 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
131 EXPORT_SYMBOL(ptlrpc_send_reply);
132 EXPORT_SYMBOL(ptlrpc_reply);
133 EXPORT_SYMBOL(ptlrpc_error);
134 EXPORT_SYMBOL(ptlrpc_resend_req);
135 EXPORT_SYMBOL(ptl_send_rpc);
136
137 /* client.c */
138 EXPORT_SYMBOL(ptlrpc_init_client);
139 EXPORT_SYMBOL(ptlrpc_cleanup_client);
140 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
141 EXPORT_SYMBOL(ptlrpc_queue_wait);
142 EXPORT_SYMBOL(ptlrpc_replay_req);
143 EXPORT_SYMBOL(ptlrpc_restart_req);
144 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
145 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
146 EXPORT_SYMBOL(ptlrpc_free_rq_pool);
147 EXPORT_SYMBOL(ptlrpc_prep_req_pool);
148 EXPORT_SYMBOL(ptlrpc_prep_req);
149 EXPORT_SYMBOL(ptlrpc_free_req);
150 EXPORT_SYMBOL(ptlrpc_unregister_reply);
151 EXPORT_SYMBOL(ptlrpc_req_finished);
152 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
153 EXPORT_SYMBOL(ptlrpc_request_addref);
154 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
155 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
156 EXPORT_SYMBOL(ptlrpc_free_bulk);
157 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
158 EXPORT_SYMBOL(ptlrpc_abort_inflight);
159 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
160 EXPORT_SYMBOL(ptlrpc_next_xid);
161
162 EXPORT_SYMBOL(ptlrpc_prep_set);
163 EXPORT_SYMBOL(ptlrpc_set_add_cb);
164 EXPORT_SYMBOL(ptlrpc_set_add_req);
165 EXPORT_SYMBOL(ptlrpc_set_add_new_req);
166 EXPORT_SYMBOL(ptlrpc_set_destroy);
167 EXPORT_SYMBOL(ptlrpc_set_next_timeout);
168 EXPORT_SYMBOL(ptlrpc_check_set);
169 EXPORT_SYMBOL(ptlrpc_set_wait);
170 EXPORT_SYMBOL(ptlrpc_expired_set);
171 EXPORT_SYMBOL(ptlrpc_interrupted_set);
172 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
173
174 /* service.c */
175 EXPORT_SYMBOL(ptlrpc_save_lock);
176 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
177 EXPORT_SYMBOL(ptlrpc_commit_replies);
178 EXPORT_SYMBOL(ptlrpc_init_svc);
179 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
180 EXPORT_SYMBOL(ptlrpc_start_threads);
181 EXPORT_SYMBOL(ptlrpc_start_thread);
182 EXPORT_SYMBOL(ptlrpc_unregister_service);
183 EXPORT_SYMBOL(ptlrpc_daemonize);
184 EXPORT_SYMBOL(ptlrpc_service_health_check);
185
186 /* pack_generic.c */
187 EXPORT_SYMBOL(lustre_msg_swabbed);
188 EXPORT_SYMBOL(lustre_msg_check_version);
189 EXPORT_SYMBOL(lustre_pack_request);
190 EXPORT_SYMBOL(lustre_pack_reply);
191 EXPORT_SYMBOL(lustre_pack_reply_flags);
192 EXPORT_SYMBOL(lustre_shrink_reply);
193 EXPORT_SYMBOL(lustre_free_reply_state);
194 EXPORT_SYMBOL(lustre_msg_size);
195 EXPORT_SYMBOL(lustre_unpack_msg);
196 EXPORT_SYMBOL(lustre_msg_buf);
197 EXPORT_SYMBOL(lustre_msg_string);
198 EXPORT_SYMBOL(lustre_swab_buf);
199 EXPORT_SYMBOL(lustre_swab_reqbuf);
200 EXPORT_SYMBOL(lustre_swab_repbuf);
201 EXPORT_SYMBOL(lustre_swab_obdo);
202 EXPORT_SYMBOL(lustre_swab_obd_statfs);
203 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
204 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
205 EXPORT_SYMBOL(lustre_swab_ost_body);
206 EXPORT_SYMBOL(lustre_swab_ost_last_id);
207 EXPORT_SYMBOL(lustre_swab_ost_lvb);
208 EXPORT_SYMBOL(lustre_swab_mds_status_req);
209 EXPORT_SYMBOL(lustre_swab_mds_body);
210 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
211 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
212 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
213 EXPORT_SYMBOL(lustre_swab_mds_rec_join);
214 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
215 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
216 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
217 EXPORT_SYMBOL(lustre_swab_lov_desc);
218 EXPORT_SYMBOL(lustre_swab_lov_user_md);
219 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
220 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
221 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
222 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
223 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
224 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
225 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
226 EXPORT_SYMBOL(lustre_swab_ldlm_request);
227 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
228 EXPORT_SYMBOL(lustre_swab_qdata);
229 EXPORT_SYMBOL(lustre_swab_qdata_old);
230 EXPORT_SYMBOL(lustre_msg_get_flags);
231 EXPORT_SYMBOL(lustre_msg_add_flags);
232 EXPORT_SYMBOL(lustre_msg_set_flags);
233 EXPORT_SYMBOL(lustre_msg_clear_flags);
234 EXPORT_SYMBOL(lustre_msg_get_op_flags);
235 EXPORT_SYMBOL(lustre_msg_add_op_flags);
236 EXPORT_SYMBOL(lustre_msg_set_op_flags);
237 EXPORT_SYMBOL(lustre_msg_get_handle );
238 EXPORT_SYMBOL(lustre_msg_get_type);
239 EXPORT_SYMBOL(lustre_msg_get_version);
240 EXPORT_SYMBOL(lustre_msg_add_version);
241 EXPORT_SYMBOL(lustre_msg_get_opc);
242 EXPORT_SYMBOL(lustre_msg_get_last_xid);
243 EXPORT_SYMBOL(lustre_msg_get_last_committed);
244 EXPORT_SYMBOL(lustre_msg_get_transno);
245 EXPORT_SYMBOL(lustre_msg_get_status);
246 EXPORT_SYMBOL(lustre_msg_get_slv);
247 EXPORT_SYMBOL(lustre_msg_get_limit);
248 EXPORT_SYMBOL(lustre_msg_set_slv);
249 EXPORT_SYMBOL(lustre_msg_set_limit);
250 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
251 EXPORT_SYMBOL(lustre_msg_is_v1);
252 EXPORT_SYMBOL(lustre_msg_get_magic);
253 EXPORT_SYMBOL(lustre_msg_set_handle);
254 EXPORT_SYMBOL(lustre_msg_set_type);
255 EXPORT_SYMBOL(lustre_msg_set_opc);
256 EXPORT_SYMBOL(lustre_msg_set_last_xid);
257 EXPORT_SYMBOL(lustre_msg_set_last_committed);
258 EXPORT_SYMBOL(lustre_msg_set_transno);
259 EXPORT_SYMBOL(lustre_msg_set_status);
260 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
261 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
262
263 /* recover.c */
264 EXPORT_SYMBOL(ptlrpc_disconnect_import);
265 EXPORT_SYMBOL(ptlrpc_resend);
266 EXPORT_SYMBOL(ptlrpc_wake_delayed);
267 EXPORT_SYMBOL(ptlrpc_set_import_active);
268 EXPORT_SYMBOL(ptlrpc_activate_import);
269 EXPORT_SYMBOL(ptlrpc_deactivate_import);
270 EXPORT_SYMBOL(ptlrpc_invalidate_import);
271 EXPORT_SYMBOL(ptlrpc_fail_import);
272 EXPORT_SYMBOL(ptlrpc_recover_import);
273 EXPORT_SYMBOL(ptlrpc_import_setasync);
274
275 /* pinger.c */
276 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
277 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
278 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
279
280 /* ptlrpcd.c */
281 EXPORT_SYMBOL(ptlrpcd_addref);
282 EXPORT_SYMBOL(ptlrpcd_decref);
283 EXPORT_SYMBOL(ptlrpcd_add_req);
284 EXPORT_SYMBOL(ptlrpcd_wake);
285
286 /* llogd.c */
287 EXPORT_SYMBOL(llog_origin_handle_create);
288 EXPORT_SYMBOL(llog_origin_handle_destroy);
289 EXPORT_SYMBOL(llog_origin_handle_next_block);
290 EXPORT_SYMBOL(llog_origin_handle_prev_block);
291 EXPORT_SYMBOL(llog_origin_handle_read_header);
292 EXPORT_SYMBOL(llog_origin_handle_close);
293 EXPORT_SYMBOL(llog_client_ops);
294 EXPORT_SYMBOL(llog_catinfo);
295
296 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
297 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
298 MODULE_LICENSE("GPL");
299
300 cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
301 #endif