Whamcloud - gitweb
182537ec1969043b77f8788df7a399cc8341c697
[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 #ifdef __KERNEL__
32 # include <linux/module.h>
33 # include <linux/init.h>
34 #else
35 # include <liblustre.h>
36 #endif
37
38 #include <linux/obd_support.h>
39 #include <linux/obd_class.h>
40 #include <linux/lustre_net.h>
41
42 #include "ptlrpc_internal.h"
43
44 extern int ptlrpc_init_portals(void);
45 extern void ptlrpc_exit_portals(void);
46
47 __init int ptlrpc_init(void)
48 {
49         int rc, cleanup_phase = 0;
50         ENTRY;
51
52         lustre_assert_wire_constants();
53
54         rc = ptlrpc_init_portals();
55         if (rc)
56                 RETURN(rc);
57         cleanup_phase = 1;
58
59         ptlrpc_init_connection();
60         rc = llog_init_commit_master();
61         if (rc)
62                 GOTO(cleanup, rc);
63         cleanup_phase = 2;
64
65         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
66         ptlrpc_abort_inflight_superhack = ptlrpc_abort_inflight;
67
68         rc = ptlrpc_start_pinger();
69         if (rc)
70                 GOTO(cleanup, rc);
71         cleanup_phase = 3;
72
73         rc = ldlm_init();
74         if (rc)
75                 GOTO(cleanup, rc);
76         RETURN(0);
77
78 cleanup:
79         switch(cleanup_phase) {
80         case 3:
81                 ptlrpc_stop_pinger();
82         case 2:
83                 llog_cleanup_commit_master(1);
84                 ptlrpc_cleanup_connection();
85         case 1:
86                 ptlrpc_exit_portals();
87         default: ;
88         }
89
90         return rc;
91 }
92
93 #ifdef __KERNEL__
94 static void __exit ptlrpc_exit(void)
95 {
96         ldlm_exit();
97         ptlrpc_stop_pinger();
98         ptlrpc_exit_portals();
99         ptlrpc_cleanup_connection();
100         llog_cleanup_commit_master(0);
101 }
102
103 /* connection.c */
104 EXPORT_SYMBOL(ptlrpc_dump_connections);
105 EXPORT_SYMBOL(ptlrpc_readdress_connection);
106 EXPORT_SYMBOL(ptlrpc_get_connection);
107 EXPORT_SYMBOL(ptlrpc_put_connection);
108 EXPORT_SYMBOL(ptlrpc_connection_addref);
109 EXPORT_SYMBOL(ptlrpc_init_connection);
110 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
111
112 /* niobuf.c */
113 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
114 EXPORT_SYMBOL(ptlrpc_abort_bulk);
115 EXPORT_SYMBOL(ptlrpc_register_bulk);
116 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
117 EXPORT_SYMBOL(ptlrpc_send_reply);
118 EXPORT_SYMBOL(ptlrpc_reply);
119 EXPORT_SYMBOL(ptlrpc_error);
120 EXPORT_SYMBOL(ptlrpc_resend_req);
121 EXPORT_SYMBOL(ptl_send_rpc);
122
123 /* client.c */
124 EXPORT_SYMBOL(ptlrpc_init_client);
125 EXPORT_SYMBOL(ptlrpc_cleanup_client);
126 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
127 EXPORT_SYMBOL(ptlrpc_queue_wait);
128 EXPORT_SYMBOL(ptlrpc_replay_req);
129 EXPORT_SYMBOL(ptlrpc_restart_req);
130 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
131 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
132 EXPORT_SYMBOL(ptlrpc_free_rq_pool);
133 EXPORT_SYMBOL(ptlrpc_prep_req_pool);
134 EXPORT_SYMBOL(ptlrpc_prep_req);
135 EXPORT_SYMBOL(ptlrpc_free_req);
136 EXPORT_SYMBOL(ptlrpc_unregister_reply);
137 EXPORT_SYMBOL(ptlrpc_req_finished);
138 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
139 EXPORT_SYMBOL(ptlrpc_request_addref);
140 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
141 EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
142 EXPORT_SYMBOL(ptlrpc_free_bulk);
143 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
144 EXPORT_SYMBOL(ptlrpc_abort_inflight);
145 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
146 EXPORT_SYMBOL(ptlrpc_next_xid);
147
148 EXPORT_SYMBOL(ptlrpc_prep_set);
149 EXPORT_SYMBOL(ptlrpc_set_add_req);
150 EXPORT_SYMBOL(ptlrpc_set_add_new_req);
151 EXPORT_SYMBOL(ptlrpc_set_destroy);
152 EXPORT_SYMBOL(ptlrpc_set_next_timeout);
153 EXPORT_SYMBOL(ptlrpc_check_set);
154 EXPORT_SYMBOL(ptlrpc_set_wait);
155 EXPORT_SYMBOL(ptlrpc_expired_set);
156 EXPORT_SYMBOL(ptlrpc_interrupted_set);
157 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
158
159 /* service.c */
160 EXPORT_SYMBOL(ptlrpc_save_lock);
161 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
162 EXPORT_SYMBOL(ptlrpc_commit_replies);
163 EXPORT_SYMBOL(ptlrpc_init_svc);
164 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
165 EXPORT_SYMBOL(ptlrpc_start_threads);
166 EXPORT_SYMBOL(ptlrpc_start_thread);
167 EXPORT_SYMBOL(ptlrpc_unregister_service);
168 EXPORT_SYMBOL(ptlrpc_daemonize);
169 EXPORT_SYMBOL(ptlrpc_service_health_check);
170
171 /* pack_generic.c */
172 EXPORT_SYMBOL(lustre_msg_swabbed);
173 EXPORT_SYMBOL(lustre_msg_check_version);
174 EXPORT_SYMBOL(lustre_pack_request);
175 EXPORT_SYMBOL(lustre_pack_reply);
176 EXPORT_SYMBOL(lustre_shrink_reply);
177 EXPORT_SYMBOL(lustre_free_reply_state);
178 EXPORT_SYMBOL(lustre_msg_size);
179 EXPORT_SYMBOL(lustre_unpack_msg);
180 EXPORT_SYMBOL(lustre_msg_buf);
181 EXPORT_SYMBOL(lustre_msg_string);
182 EXPORT_SYMBOL(lustre_swab_buf);
183 EXPORT_SYMBOL(lustre_swab_reqbuf);
184 EXPORT_SYMBOL(lustre_swab_repbuf);
185 EXPORT_SYMBOL(lustre_swab_obdo);
186 EXPORT_SYMBOL(lustre_swab_obd_statfs);
187 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
188 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
189 EXPORT_SYMBOL(lustre_swab_ost_body);
190 EXPORT_SYMBOL(lustre_swab_ost_last_id);
191 EXPORT_SYMBOL(lustre_swab_ost_lvb);
192 EXPORT_SYMBOL(lustre_swab_mds_status_req);
193 EXPORT_SYMBOL(lustre_swab_mds_body);
194 EXPORT_SYMBOL(lustre_swab_mdt_body);
195 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
196 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
197 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
198 EXPORT_SYMBOL(lustre_swab_mds_rec_join);
199 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
200 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
201 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
202 EXPORT_SYMBOL(lustre_swab_lov_desc);
203 EXPORT_SYMBOL(lustre_swab_lov_user_md);
204 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
205 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
206 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
207 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
208 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
209 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
210 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
211 EXPORT_SYMBOL(lustre_swab_ldlm_request);
212 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
213 EXPORT_SYMBOL(lustre_swab_qdata);
214 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
215
216 /* recover.c */
217 EXPORT_SYMBOL(ptlrpc_run_recovery_over_upcall);
218 EXPORT_SYMBOL(ptlrpc_run_failed_import_upcall);
219 EXPORT_SYMBOL(ptlrpc_disconnect_import);
220 EXPORT_SYMBOL(ptlrpc_resend);
221 EXPORT_SYMBOL(ptlrpc_wake_delayed);
222 EXPORT_SYMBOL(ptlrpc_set_import_active);
223 EXPORT_SYMBOL(ptlrpc_activate_import);
224 EXPORT_SYMBOL(ptlrpc_deactivate_import);
225 EXPORT_SYMBOL(ptlrpc_invalidate_import);
226 EXPORT_SYMBOL(ptlrpc_fail_import);
227 EXPORT_SYMBOL(ptlrpc_recover_import);
228
229 /* pinger.c */
230 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
231 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
232 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
233
234 /* ptlrpcd.c */
235 EXPORT_SYMBOL(ptlrpcd_addref);
236 EXPORT_SYMBOL(ptlrpcd_decref);
237 EXPORT_SYMBOL(ptlrpcd_add_req);
238 EXPORT_SYMBOL(ptlrpcd_wake);
239
240 /* llogd.c */
241 EXPORT_SYMBOL(llog_origin_handle_create);
242 EXPORT_SYMBOL(llog_origin_handle_destroy);
243 EXPORT_SYMBOL(llog_origin_handle_next_block);
244 EXPORT_SYMBOL(llog_origin_handle_prev_block);
245 EXPORT_SYMBOL(llog_origin_handle_read_header);
246 EXPORT_SYMBOL(llog_origin_handle_close);
247 EXPORT_SYMBOL(llog_client_ops);
248 EXPORT_SYMBOL(llog_catinfo);
249
250 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
251 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
252 MODULE_LICENSE("GPL");
253
254 module_init(ptlrpc_init);
255 module_exit(ptlrpc_exit);
256 #endif