Whamcloud - gitweb
if client_disconnect_export was called without force flag set,
[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 #include <lustre_req_layout.h>
39
40 #include "ptlrpc_internal.h"
41
42 extern spinlock_t ptlrpc_last_xid_lock;
43 extern spinlock_t ptlrpc_rs_debug_lock;
44 extern spinlock_t ptlrpc_all_services_lock;
45 extern struct semaphore pinger_sem;
46 extern struct semaphore ptlrpcd_sem;
47 extern int ptlrpc_init_portals(void);
48 extern void ptlrpc_exit_portals(void);
49
50 __init int ptlrpc_init(void)
51 {
52         int rc, cleanup_phase = 0;
53         ENTRY;
54
55         lustre_assert_wire_constants();
56         spin_lock_init(&ptlrpc_last_xid_lock);
57         spin_lock_init(&ptlrpc_rs_debug_lock);
58         spin_lock_init(&ptlrpc_all_services_lock);
59         init_mutex(&pinger_sem);
60         init_mutex(&ptlrpcd_sem);
61
62         rc = req_layout_init();
63         if (rc)
64                 RETURN(rc);
65         cleanup_phase = 1;
66
67         rc = ptlrpc_init_portals();
68         if (rc)
69                 RETURN(rc);
70         cleanup_phase = 2;
71
72         ptlrpc_init_connection();
73         if (rc)
74                 GOTO(cleanup, rc);
75         cleanup_phase = 3;
76
77         rc = llog_init_commit_master();
78         if (rc)
79                 GOTO(cleanup, rc);
80         cleanup_phase = 4;
81
82         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
83
84         rc = ptlrpc_start_pinger();
85         if (rc)
86                 GOTO(cleanup, rc);
87         cleanup_phase = 5;
88
89         rc = ldlm_init();
90         if (rc)
91                 GOTO(cleanup, rc);
92         cleanup_phase = 6;
93
94         rc = sptlrpc_init();
95         if (rc)
96                 GOTO(cleanup, rc);
97
98         RETURN(0);
99
100 cleanup:
101         switch(cleanup_phase) {
102         case 6:
103                 ldlm_exit();
104         case 5:
105                 ptlrpc_stop_pinger();
106         case 4:
107                 llog_cleanup_commit_master(1);
108         case 3:
109                 ptlrpc_cleanup_connection();
110         case 2:
111                 ptlrpc_exit_portals();
112         case 1:
113                 req_layout_fini();
114         default: ;
115         }
116
117         return rc;
118 }
119
120 #ifdef __KERNEL__
121 static void __exit ptlrpc_exit(void)
122 {
123         sptlrpc_fini();
124         ldlm_exit();
125         ptlrpc_stop_pinger();
126         ptlrpc_exit_portals();
127         ptlrpc_cleanup_connection();
128         llog_cleanup_commit_master(0);
129 }
130
131 /* connection.c */
132 EXPORT_SYMBOL(ptlrpc_dump_connections);
133 EXPORT_SYMBOL(ptlrpc_readdress_connection);
134 EXPORT_SYMBOL(ptlrpc_get_connection);
135 EXPORT_SYMBOL(ptlrpc_put_connection);
136 EXPORT_SYMBOL(ptlrpc_connection_addref);
137 EXPORT_SYMBOL(ptlrpc_init_connection);
138 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
139
140 /* niobuf.c */
141 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
142 EXPORT_SYMBOL(ptlrpc_abort_bulk);
143 EXPORT_SYMBOL(ptlrpc_register_bulk);
144 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
145 EXPORT_SYMBOL(ptlrpc_send_reply);
146 EXPORT_SYMBOL(ptlrpc_reply);
147 EXPORT_SYMBOL(ptlrpc_error);
148 EXPORT_SYMBOL(ptlrpc_resend_req);
149 EXPORT_SYMBOL(ptl_send_rpc);
150
151 /* client.c */
152 EXPORT_SYMBOL(ptlrpc_init_client);
153 EXPORT_SYMBOL(ptlrpc_cleanup_client);
154 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
155 EXPORT_SYMBOL(ptlrpc_queue_wait);
156 EXPORT_SYMBOL(ptlrpc_replay_req);
157 EXPORT_SYMBOL(ptlrpc_restart_req);
158 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
159 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
160 EXPORT_SYMBOL(ptlrpc_free_rq_pool);
161 EXPORT_SYMBOL(ptlrpc_prep_req_pool);
162 EXPORT_SYMBOL(ptlrpc_prep_req);
163 EXPORT_SYMBOL(ptlrpc_free_req);
164 EXPORT_SYMBOL(ptlrpc_unregister_reply);
165 EXPORT_SYMBOL(ptlrpc_req_finished);
166 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
167 EXPORT_SYMBOL(ptlrpc_request_addref);
168 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
169 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
170 EXPORT_SYMBOL(ptlrpc_free_bulk);
171 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
172 EXPORT_SYMBOL(ptlrpc_abort_inflight);
173 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
174 EXPORT_SYMBOL(ptlrpc_next_xid);
175
176 EXPORT_SYMBOL(ptlrpc_prep_set);
177 EXPORT_SYMBOL(ptlrpc_set_add_req);
178 EXPORT_SYMBOL(ptlrpc_set_add_new_req);
179 EXPORT_SYMBOL(ptlrpc_set_destroy);
180 EXPORT_SYMBOL(ptlrpc_set_next_timeout);
181 EXPORT_SYMBOL(ptlrpc_check_set);
182 EXPORT_SYMBOL(ptlrpc_set_wait);
183 EXPORT_SYMBOL(ptlrpc_expired_set);
184 EXPORT_SYMBOL(ptlrpc_interrupted_set);
185 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
186
187 /* service.c */
188 EXPORT_SYMBOL(ptlrpc_save_lock);
189 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
190 EXPORT_SYMBOL(ptlrpc_commit_replies);
191 EXPORT_SYMBOL(ptlrpc_init_svc);
192 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
193 EXPORT_SYMBOL(ptlrpc_start_threads);
194 EXPORT_SYMBOL(ptlrpc_start_thread);
195 EXPORT_SYMBOL(ptlrpc_unregister_service);
196 EXPORT_SYMBOL(ptlrpc_daemonize);
197 EXPORT_SYMBOL(ptlrpc_service_health_check);
198
199 /* pack_generic.c */
200 EXPORT_SYMBOL(lustre_msg_swabbed);
201 EXPORT_SYMBOL(lustre_msg_check_version);
202 EXPORT_SYMBOL(lustre_pack_request);
203 EXPORT_SYMBOL(lustre_pack_reply);
204 EXPORT_SYMBOL(lustre_shrink_msg);
205 EXPORT_SYMBOL(lustre_free_reply_state);
206 EXPORT_SYMBOL(lustre_msg_size);
207 EXPORT_SYMBOL(lustre_unpack_msg);
208 EXPORT_SYMBOL(lustre_msg_buf);
209 EXPORT_SYMBOL(lustre_msg_string);
210 EXPORT_SYMBOL(lustre_swab_ptlrpc_body);
211 EXPORT_SYMBOL(lustre_swab_buf);
212 EXPORT_SYMBOL(lustre_swab_reqbuf);
213 EXPORT_SYMBOL(lustre_swab_repbuf);
214 EXPORT_SYMBOL(lustre_swab_obdo);
215 EXPORT_SYMBOL(lustre_swab_obd_statfs);
216 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
217 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
218 EXPORT_SYMBOL(lustre_swab_ost_body);
219 EXPORT_SYMBOL(lustre_swab_ost_last_id);
220 EXPORT_SYMBOL(lustre_swab_ost_lvb);
221 EXPORT_SYMBOL(lustre_swab_mds_status_req);
222 EXPORT_SYMBOL(lustre_swab_mds_body);
223 EXPORT_SYMBOL(lustre_swab_mdt_body);
224 EXPORT_SYMBOL(lustre_swab_mdt_epoch);
225 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
226 EXPORT_SYMBOL(lustre_swab_mds_remote_perm);
227 EXPORT_SYMBOL(lustre_swab_mdt_remote_perm);
228 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
229 EXPORT_SYMBOL(lustre_swab_mdt_rec_setattr);
230 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
231 EXPORT_SYMBOL(lustre_swab_mdt_rec_create);
232 EXPORT_SYMBOL(lustre_swab_mds_rec_join);
233 EXPORT_SYMBOL(lustre_swab_mdt_rec_join);
234 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
235 EXPORT_SYMBOL(lustre_swab_mdt_rec_link);
236 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
237 EXPORT_SYMBOL(lustre_swab_mdt_rec_unlink);
238 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
239 EXPORT_SYMBOL(lustre_swab_mdt_rec_rename);
240 EXPORT_SYMBOL(lustre_swab_lov_desc);
241 EXPORT_SYMBOL(lustre_swab_lov_user_md);
242 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
243 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
244 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
245 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
246 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
247 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
248 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
249 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
250 EXPORT_SYMBOL(lustre_swab_ldlm_request);
251 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
252 EXPORT_SYMBOL(lustre_swab_qdata);
253 EXPORT_SYMBOL(lustre_swab_qdata_old);
254 EXPORT_SYMBOL(lustre_msg_get_flags);
255 EXPORT_SYMBOL(lustre_msg_add_flags);
256 EXPORT_SYMBOL(lustre_msg_set_flags);
257 EXPORT_SYMBOL(lustre_msg_clear_flags);
258 EXPORT_SYMBOL(lustre_msg_get_op_flags);
259 EXPORT_SYMBOL(lustre_msg_add_op_flags);
260 EXPORT_SYMBOL(lustre_msg_set_op_flags);
261 EXPORT_SYMBOL(lustre_msg_get_handle );
262 EXPORT_SYMBOL(lustre_msg_get_type);
263 EXPORT_SYMBOL(lustre_msg_get_version);
264 EXPORT_SYMBOL(lustre_msg_add_version);
265 EXPORT_SYMBOL(lustre_msg_get_opc);
266 EXPORT_SYMBOL(lustre_msg_get_last_xid);
267 EXPORT_SYMBOL(lustre_msg_get_last_committed);
268 EXPORT_SYMBOL(lustre_msg_get_transno);
269 EXPORT_SYMBOL(lustre_msg_get_status);
270 EXPORT_SYMBOL(lustre_msg_get_slv);
271 EXPORT_SYMBOL(lustre_msg_get_limit);
272 EXPORT_SYMBOL(lustre_msg_set_slv);
273 EXPORT_SYMBOL(lustre_msg_set_limit);
274 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
275 EXPORT_SYMBOL(lustre_msg_get_magic);
276 EXPORT_SYMBOL(lustre_msg_set_handle);
277 EXPORT_SYMBOL(lustre_msg_set_type);
278 EXPORT_SYMBOL(lustre_msg_set_opc);
279 EXPORT_SYMBOL(lustre_msg_set_last_xid);
280 EXPORT_SYMBOL(lustre_msg_set_last_committed);
281 EXPORT_SYMBOL(lustre_msg_set_transno);
282 EXPORT_SYMBOL(lustre_msg_set_status);
283 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
284 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
285 EXPORT_SYMBOL(lustre_swab_md_fld);
286 EXPORT_SYMBOL(lustre_swab_generic_32s);
287 EXPORT_SYMBOL(lustre_swab_lustre_capa);
288 EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
289
290 /* recover.c */
291 EXPORT_SYMBOL(ptlrpc_disconnect_import);
292 EXPORT_SYMBOL(ptlrpc_resend);
293 EXPORT_SYMBOL(ptlrpc_wake_delayed);
294 EXPORT_SYMBOL(ptlrpc_set_import_active);
295 EXPORT_SYMBOL(ptlrpc_activate_import);
296 EXPORT_SYMBOL(ptlrpc_deactivate_import);
297 EXPORT_SYMBOL(ptlrpc_invalidate_import);
298 EXPORT_SYMBOL(ptlrpc_fail_import);
299 EXPORT_SYMBOL(ptlrpc_recover_import);
300
301 /* pinger.c */
302 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
303 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
304 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
305
306 /* ptlrpcd.c */
307 EXPORT_SYMBOL(ptlrpcd_addref);
308 EXPORT_SYMBOL(ptlrpcd_decref);
309 EXPORT_SYMBOL(ptlrpcd_add_req);
310 EXPORT_SYMBOL(ptlrpcd_wake);
311
312 /* llogd.c */
313 EXPORT_SYMBOL(llog_origin_handle_create);
314 EXPORT_SYMBOL(llog_origin_handle_destroy);
315 EXPORT_SYMBOL(llog_origin_handle_next_block);
316 EXPORT_SYMBOL(llog_origin_handle_prev_block);
317 EXPORT_SYMBOL(llog_origin_handle_read_header);
318 EXPORT_SYMBOL(llog_origin_handle_close);
319 EXPORT_SYMBOL(llog_client_ops);
320 EXPORT_SYMBOL(llog_catinfo);
321
322 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
323 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
324 MODULE_LICENSE("GPL");
325
326 cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
327 #endif