Whamcloud - gitweb
Do lots of explicit EXPORT_SYMBOLs to see if this cures ia64 problems
[fs/lustre-release.git] / lustre / ptlrpc / rpc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #define EXPORT_SYMTAB
24 #define DEBUG_SUBSYSTEM S_RPC
25
26 #include <linux/module.h>
27 #include <linux/lustre_ha.h>
28
29 extern int ptlrpc_init_portals(void);
30 extern void ptlrpc_exit_portals(void);
31
32 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
33 {
34         struct recovd_obd *recovd = &obddev->u.recovd;
35         int err;
36         ENTRY;
37
38         memset(recovd, 0, sizeof(*recovd));
39
40         OBD_ALLOC(recovd->recovd_client, sizeof(*recovd->recovd_client));
41         if (!recovd)
42                 RETURN(-ENOMEM);
43
44         err = recovd_setup(recovd);
45         if (err)
46                 GOTO(err_free, err);
47
48         recovd->recovd_service =
49                 ptlrpc_init_svc(128 * 1024,CONNMGR_REQUEST_PORTAL,
50                                 CONNMGR_REPLY_PORTAL, "self", connmgr_handle);
51         if (!recovd->recovd_service) {
52                 CERROR("failed to start service\n");
53                 GOTO(err_recovd, err = -EINVAL);
54         }
55
56         ptlrpc_init_client(NULL, NULL, CONNMGR_REQUEST_PORTAL, 
57                            CONNMGR_REPLY_PORTAL, recovd->recovd_client);
58         recovd->recovd_client->cli_name = "connmgr"; 
59
60         err = ptlrpc_start_thread(obddev, recovd->recovd_service, "lustre_connmgr");
61         if (err) {
62                 CERROR("cannot start thread\n");
63                 GOTO(err_svc, err);
64         }
65
66         MOD_INC_USE_COUNT;
67         ptlrpc_connmgr = recovd;
68         RETURN(0);
69
70  err_svc: 
71         rpc_unregister_service(recovd->recovd_service);
72  err_recovd: 
73         recovd_cleanup(recovd); 
74  err_free:
75         if (recovd->recovd_client)
76                 OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
77         RETURN(err);
78 }
79
80 int connmgr_cleanup(struct obd_device *dev)
81 {
82         struct recovd_obd *recovd = &dev->u.recovd;
83         int err;
84
85         err = recovd_cleanup(recovd); 
86         if (err) 
87                 LBUG();
88
89         ptlrpc_stop_all_threads(recovd->recovd_service);
90         rpc_unregister_service(recovd->recovd_service);
91         if (!list_empty(&recovd->recovd_service->srv_reqs)) {
92                 // XXX reply with errors and clean up
93                 CERROR("Request list not empty!\n");
94         }
95
96         OBD_FREE(recovd->recovd_service, sizeof(*recovd->recovd_service));
97         ptlrpc_cleanup_client(recovd->recovd_client);
98         OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
99         MOD_DEC_USE_COUNT;
100         RETURN(0);
101 }
102
103
104 int connmgr_iocontrol(long cmd, struct obd_conn *conn, int len, void *karg,
105                       void *uarg)
106 {
107         struct recovd_obd *recovd = &conn->oc_dev->u.recovd;
108
109         ENTRY;
110         if (cmd == OBD_RECOVD_NEWCONN) { 
111                 spin_lock(&recovd->recovd_lock);
112                 recovd->recovd_flags |= RECOVD_UPCALL_ANSWER;
113                 recovd->recovd_wakeup_flag = 1;
114                 wake_up(&recovd->recovd_waitq);
115                 spin_unlock(&recovd->recovd_lock);
116                 EXIT;
117         }
118         return 0;
119 }
120
121
122 /* use obd ops to offer management infrastructure */
123 static struct obd_ops recovd_obd_ops = {
124         o_setup:       connmgr_setup,
125         o_cleanup:     connmgr_cleanup,
126         o_iocontrol:     connmgr_iocontrol,
127 };
128
129 static int __init ptlrpc_init(void)
130 {
131         int rc; 
132         rc = ptlrpc_init_portals();
133         if (rc) 
134                 RETURN(rc);
135         ptlrpc_init_connection();
136         obd_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
137         return 0;
138 }
139
140 static void __exit ptlrpc_exit(void)
141 {
142         obd_unregister_type(LUSTRE_HA_NAME);
143         ptlrpc_exit_portals();
144         ptlrpc_cleanup_connection();
145 }
146
147 /* connection.c */
148 EXPORT_SYMBOL(ptlrpc_readdress_connection);
149 EXPORT_SYMBOL(ptlrpc_get_connection);
150 EXPORT_SYMBOL(ptlrpc_put_connection);
151 EXPORT_SYMBOL(ptlrpc_connection_addref);
152 EXPORT_SYMBOL(ptlrpc_init_connection);
153 EXPORT_SYMBOL(ptlrpc_cleanup_connection);
154
155 /* niobuf.c */
156 EXPORT_SYMBOL(ptlrpc_send_bulk);
157 EXPORT_SYMBOL(ptlrpc_register_bulk);
158 EXPORT_SYMBOL(ptlrpc_abort_bulk);
159 EXPORT_SYMBOL(ptlrpc_reply);
160 EXPORT_SYMBOL(ptlrpc_error);
161 EXPORT_SYMBOL(ptlrpc_resend_req);
162 EXPORT_SYMBOL(ptl_send_rpc);
163 EXPORT_SYMBOL(ptlrpc_link_svc_me);
164
165 /* client.c */
166 EXPORT_SYMBOL(ptlrpc_init_client);
167 EXPORT_SYMBOL(ptlrpc_cleanup_client);
168 EXPORT_SYMBOL(ptlrpc_req_to_uuid);
169 EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
170 EXPORT_SYMBOL(ptlrpc_queue_wait);
171 EXPORT_SYMBOL(ptlrpc_continue_req);
172 EXPORT_SYMBOL(ptlrpc_replay_req);
173 EXPORT_SYMBOL(ptlrpc_restart_req);
174 EXPORT_SYMBOL(ptlrpc_prep_req);
175 EXPORT_SYMBOL(ptlrpc_free_req);
176 EXPORT_SYMBOL(ptlrpc_req_finished);
177 EXPORT_SYMBOL(ptlrpc_prep_bulk);
178 EXPORT_SYMBOL(ptlrpc_free_bulk);
179 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
180 EXPORT_SYMBOL(ptlrpc_free_bulk_page);
181 EXPORT_SYMBOL(ptlrpc_check_status);
182
183 /* service.c */
184 EXPORT_SYMBOL(ptlrpc_init_svc);
185 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
186 EXPORT_SYMBOL(ptlrpc_start_thread);
187 EXPORT_SYMBOL(rpc_unregister_service);
188
189 /* pack_generic.c */
190 EXPORT_SYMBOL(lustre_pack_msg);
191 EXPORT_SYMBOL(lustre_msg_size);
192 EXPORT_SYMBOL(lustre_unpack_msg);
193 EXPORT_SYMBOL(lustre_msg_buf);
194
195 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
196 MODULE_DESCRIPTION("Lustre Request Processor v1.0");
197 MODULE_LICENSE("GPL"); 
198
199 module_init(ptlrpc_init);
200 module_exit(ptlrpc_exit);