File: | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c |
Location: | line 490, column 47 |
Description: | Access to field 'req' results in a dereference of a null pointer (loaded from variable 'ctx') |
1 | /* | |||
2 | Copyright (c) 2010-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #ifndef _CONFIG_H | |||
12 | #define _CONFIG_H | |||
13 | #include "config.h" | |||
14 | #endif | |||
15 | ||||
16 | #include "rpc-clnt.h" | |||
17 | #include "glusterd1-xdr.h" | |||
18 | #include "cli1-xdr.h" | |||
19 | ||||
20 | #include "xdr-generic.h" | |||
21 | ||||
22 | #include "compat-errno.h" | |||
23 | #include "glusterd-op-sm.h" | |||
24 | #include "glusterd-sm.h" | |||
25 | #include "glusterd.h" | |||
26 | #include "protocol-common.h" | |||
27 | #include "glusterd-utils.h" | |||
28 | #include "common-utils.h" | |||
29 | #include <sys/uio.h> | |||
30 | ||||
31 | ||||
32 | #define SERVER_PATH_MAX(16 * 1024) (16 * 1024) | |||
33 | ||||
34 | ||||
35 | extern glusterd_op_info_t opinfo; | |||
36 | ||||
37 | int32_t | |||
38 | glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, | |||
39 | int32_t op_errno, rpcsvc_request_t *req, | |||
40 | void *op_ctx, char *op_errstr) | |||
41 | { | |||
42 | int32_t ret = -1; | |||
43 | void *cli_rsp = NULL((void*)0); | |||
44 | dict_t *ctx = NULL((void*)0); | |||
45 | char *free_ptr = NULL((void*)0); | |||
46 | glusterd_conf_t *conf = NULL((void*)0); | |||
47 | xdrproc_t xdrproc = NULL((void*)0); | |||
48 | char *errstr = NULL((void*)0); | |||
49 | int32_t status = 0; | |||
50 | int32_t count = 0; | |||
51 | gf_cli_rsp rsp = {0,}; | |||
52 | xlator_t *this = NULL((void*)0); | |||
53 | ||||
54 | this = THIS(*__glusterfs_this_location()); | |||
55 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 55, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
56 | conf = this->private; | |||
57 | ||||
58 | GF_ASSERT (conf)do { if (!(conf)) { do { do { if (0) printf ("Assertion failed: " "conf"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 58, GF_LOG_ERROR, "Assertion failed: " "conf" ); } while (0); } } while (0); | |||
59 | ||||
60 | ctx = op_ctx; | |||
61 | ||||
62 | switch (op) { | |||
63 | case GD_OP_REMOVE_BRICK: | |||
64 | { | |||
65 | if (ctx) | |||
66 | ret = dict_get_str (ctx, "errstr", &errstr); | |||
67 | break; | |||
68 | } | |||
69 | case GD_OP_RESET_VOLUME: | |||
70 | { | |||
71 | if (op_ret && !op_errstr) | |||
72 | errstr = "Error while resetting options"; | |||
73 | break; | |||
74 | } | |||
75 | case GD_OP_REBALANCE: | |||
76 | case GD_OP_DEFRAG_BRICK_VOLUME: | |||
77 | { | |||
78 | if (ctx) { | |||
79 | ret = dict_get_int32 (ctx, "status", &status); | |||
80 | if (ret) { | |||
81 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 82, GF_LOG_TRACE, "failed to get status"); } while (0) | |||
82 | "failed to get status")do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 82, GF_LOG_TRACE, "failed to get status"); } while (0); | |||
83 | } | |||
84 | } | |||
85 | break; | |||
86 | } | |||
87 | case GD_OP_GSYNC_SET: | |||
88 | { | |||
89 | if (ctx) { | |||
90 | ret = dict_get_str (ctx, "errstr", &errstr); | |||
91 | ret = dict_set_str (ctx, "glusterd_workdir", conf->workdir); | |||
92 | /* swallow error here, that will be re-triggered in cli */ | |||
93 | ||||
94 | } | |||
95 | break; | |||
96 | ||||
97 | } | |||
98 | case GD_OP_QUOTA: | |||
99 | { | |||
100 | if (ctx && !op_errstr) { | |||
101 | ret = dict_get_str (ctx, "errstr", &errstr); | |||
102 | } | |||
103 | break; | |||
104 | } | |||
105 | case GD_OP_PROFILE_VOLUME: | |||
106 | { | |||
107 | if (ctx && dict_get_int32 (ctx, "count", &count)) { | |||
108 | ret = dict_set_int32 (ctx, "count", 0); | |||
109 | if (ret) { | |||
110 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set count in dictionary") ; } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__ , 111, GF_LOG_ERROR, "failed to set count in dictionary"); } while (0) | |||
111 | "failed to set count in dictionary")do { do { if (0) printf ("failed to set count in dictionary") ; } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__ , 111, GF_LOG_ERROR, "failed to set count in dictionary"); } while (0); | |||
112 | } | |||
113 | } | |||
114 | break; | |||
115 | } | |||
116 | case GD_OP_START_BRICK: | |||
117 | case GD_OP_STOP_BRICK: | |||
118 | { | |||
119 | gf_log (this->name, GF_LOG_DEBUG, "op '%s' not supported",do { do { if (0) printf ("op '%s' not supported", gd_op_list[ op]); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c" , __FUNCTION__, 120, GF_LOG_DEBUG, "op '%s' not supported", gd_op_list [op]); } while (0) | |||
120 | gd_op_list[op])do { do { if (0) printf ("op '%s' not supported", gd_op_list[ op]); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c" , __FUNCTION__, 120, GF_LOG_DEBUG, "op '%s' not supported", gd_op_list [op]); } while (0); | |||
121 | break; | |||
122 | } | |||
123 | case GD_OP_NONE: | |||
124 | case GD_OP_MAX: | |||
125 | { | |||
126 | gf_log (this->name, GF_LOG_ERROR, "invalid operation")do { do { if (0) printf ("invalid operation"); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 126, GF_LOG_ERROR , "invalid operation"); } while (0); | |||
127 | break; | |||
128 | } | |||
129 | case GD_OP_CREATE_VOLUME: | |||
130 | case GD_OP_START_VOLUME: | |||
131 | case GD_OP_STOP_VOLUME: | |||
132 | case GD_OP_DELETE_VOLUME: | |||
133 | case GD_OP_DEFRAG_VOLUME: | |||
134 | case GD_OP_ADD_BRICK: | |||
135 | case GD_OP_LOG_ROTATE: | |||
136 | case GD_OP_SYNC_VOLUME: | |||
137 | case GD_OP_STATEDUMP_VOLUME: | |||
138 | case GD_OP_REPLACE_BRICK: | |||
139 | case GD_OP_STATUS_VOLUME: | |||
140 | case GD_OP_SET_VOLUME: | |||
141 | case GD_OP_LIST_VOLUME: | |||
142 | case GD_OP_CLEARLOCKS_VOLUME: | |||
143 | case GD_OP_HEAL_VOLUME: | |||
144 | case GD_OP_BD_OP: | |||
145 | { | |||
146 | /*nothing specific to be done*/ | |||
147 | break; | |||
148 | } | |||
149 | } | |||
150 | ||||
151 | rsp.op_ret = op_ret; | |||
152 | rsp.op_errno = errno(*__errno_location ()); | |||
153 | if (errstr) | |||
154 | rsp.op_errstr = errstr; | |||
155 | else if (op_errstr) | |||
156 | rsp.op_errstr = op_errstr; | |||
157 | ||||
158 | if (!rsp.op_errstr) | |||
159 | rsp.op_errstr = ""; | |||
160 | ||||
161 | if (ctx) { | |||
162 | ret = dict_allocate_and_serialize (ctx, &rsp.dict.dict_val, | |||
163 | &rsp.dict.dict_len); | |||
164 | if (ret < 0 ) | |||
165 | gf_log (this->name, GF_LOG_ERROR, "failed to "do { do { if (0) printf ("failed to " "serialize buffer"); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__ , 166, GF_LOG_ERROR, "failed to " "serialize buffer"); } while (0) | |||
166 | "serialize buffer")do { do { if (0) printf ("failed to " "serialize buffer"); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__ , 166, GF_LOG_ERROR, "failed to " "serialize buffer"); } while (0); | |||
167 | else | |||
168 | free_ptr = rsp.dict.dict_val; | |||
169 | } | |||
170 | ||||
171 | /* needed by 'rebalance status' */ | |||
172 | if (status) | |||
173 | rsp.op_errno = status; | |||
174 | ||||
175 | cli_rsp = &rsp; | |||
176 | xdrproc = (xdrproc_t) xdr_gf_cli_rsp; | |||
177 | ||||
178 | glusterd_to_cli (req, cli_rsp, NULL((void*)0), 0, NULL((void*)0), | |||
179 | xdrproc, ctx); | |||
180 | ret = 0; | |||
181 | ||||
182 | GF_FREE (free_ptr)__gf_free (free_ptr); | |||
183 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 183, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
184 | return ret; | |||
185 | } | |||
186 | ||||
187 | int | |||
188 | glusterd_big_locked_cbk (struct rpc_req *req, struct iovec *iov, | |||
189 | int count, void *myframe, fop_cbk_fn_t fn) | |||
190 | { | |||
191 | glusterd_conf_t *priv = THIS(*__glusterfs_this_location())->private; | |||
192 | int ret = -1; | |||
193 | ||||
194 | synclock_lock (&priv->big_lock); | |||
195 | ret = fn (req, iov, count, myframe); | |||
196 | synclock_unlock (&priv->big_lock); | |||
197 | ||||
198 | return ret; | |||
199 | } | |||
200 | ||||
201 | int | |||
202 | __glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, | |||
203 | int count, void *myframe) | |||
204 | { | |||
205 | gd1_mgmt_probe_rsp rsp = {{0},}; | |||
206 | int ret = 0; | |||
207 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
208 | glusterd_friend_sm_event_t *event = NULL((void*)0); | |||
209 | glusterd_probe_ctx_t *ctx = NULL((void*)0); | |||
210 | ||||
211 | if (-1 == req->rpc_status) { | |||
212 | goto out; | |||
213 | } | |||
214 | ||||
215 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_probe_rsp); | |||
216 | if (ret < 0) { | |||
217 | gf_log ("", GF_LOG_ERROR, "error")do { do { if (0) printf ("error"); } while (0); _gf_log ("", "glusterd-rpc-ops.c" , __FUNCTION__, 217, GF_LOG_ERROR, "error"); } while (0); | |||
218 | //rsp.op_ret = -1; | |||
219 | //rsp.op_errno = EINVAL; | |||
220 | goto out; | |||
221 | } | |||
222 | ||||
223 | gf_log ("glusterd", GF_LOG_INFO,do { do { if (0) printf ("Received probe resp from uuid: %s, host: %s" , uuid_utoa (rsp.uuid), rsp.hostname); } while (0); _gf_log ( "glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 225, GF_LOG_INFO , "Received probe resp from uuid: %s, host: %s", uuid_utoa (rsp .uuid), rsp.hostname); } while (0) | |||
224 | "Received probe resp from uuid: %s, host: %s",do { do { if (0) printf ("Received probe resp from uuid: %s, host: %s" , uuid_utoa (rsp.uuid), rsp.hostname); } while (0); _gf_log ( "glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 225, GF_LOG_INFO , "Received probe resp from uuid: %s, host: %s", uuid_utoa (rsp .uuid), rsp.hostname); } while (0) | |||
225 | uuid_utoa (rsp.uuid), rsp.hostname)do { do { if (0) printf ("Received probe resp from uuid: %s, host: %s" , uuid_utoa (rsp.uuid), rsp.hostname); } while (0); _gf_log ( "glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 225, GF_LOG_INFO , "Received probe resp from uuid: %s, host: %s", uuid_utoa (rsp .uuid), rsp.hostname); } while (0); | |||
226 | if (rsp.op_ret != 0) { | |||
227 | ctx = ((call_frame_t *)myframe)->local; | |||
228 | ((call_frame_t *)myframe)->local = NULL((void*)0); | |||
229 | ||||
230 | GF_ASSERT (ctx)do { if (!(ctx)) { do { do { if (0) printf ("Assertion failed: " "ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 230, GF_LOG_ERROR, "Assertion failed: " "ctx" ); } while (0); } } while (0); | |||
231 | ||||
232 | if (ctx->req) { | |||
233 | glusterd_xfer_cli_probe_resp (ctx->req, rsp.op_ret, | |||
234 | rsp.op_errno, | |||
235 | rsp.op_errstr, | |||
236 | ctx->hostname, ctx->port); | |||
237 | } | |||
238 | ||||
239 | glusterd_destroy_probe_ctx (ctx); | |||
240 | (void) glusterd_friend_remove (rsp.uuid, rsp.hostname); | |||
241 | ret = rsp.op_ret; | |||
242 | goto out; | |||
243 | } | |||
244 | ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); | |||
245 | if (ret) { | |||
246 | GF_ASSERT (0)do { if (!(0)) { do { do { if (0) printf ("Assertion failed: " "0"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 246, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); } } while (0); | |||
247 | } | |||
248 | ||||
249 | if (strncasecmp (rsp.hostname, peerinfo->hostname, 1024)) { | |||
250 | gf_log (THIS->name, GF_LOG_INFO, "Host: %s with uuid: %s "do { do { if (0) printf ("Host: %s with uuid: %s " "already present in cluster with alias hostname: %s" , rsp.hostname, uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0); _gf_log ((*__glusterfs_this_location())->name , "glusterd-rpc-ops.c", __FUNCTION__, 252, GF_LOG_INFO, "Host: %s with uuid: %s " "already present in cluster with alias hostname: %s", rsp.hostname , uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0) | |||
251 | "already present in cluster with alias hostname: %s",do { do { if (0) printf ("Host: %s with uuid: %s " "already present in cluster with alias hostname: %s" , rsp.hostname, uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0); _gf_log ((*__glusterfs_this_location())->name , "glusterd-rpc-ops.c", __FUNCTION__, 252, GF_LOG_INFO, "Host: %s with uuid: %s " "already present in cluster with alias hostname: %s", rsp.hostname , uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0) | |||
252 | rsp.hostname, uuid_utoa (rsp.uuid), peerinfo->hostname)do { do { if (0) printf ("Host: %s with uuid: %s " "already present in cluster with alias hostname: %s" , rsp.hostname, uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0); _gf_log ((*__glusterfs_this_location())->name , "glusterd-rpc-ops.c", __FUNCTION__, 252, GF_LOG_INFO, "Host: %s with uuid: %s " "already present in cluster with alias hostname: %s", rsp.hostname , uuid_utoa (rsp.uuid), peerinfo->hostname); } while (0); | |||
253 | ||||
254 | ctx = ((call_frame_t *)myframe)->local; | |||
255 | ((call_frame_t *)myframe)->local = NULL((void*)0); | |||
256 | ||||
257 | GF_ASSERT (ctx)do { if (!(ctx)) { do { do { if (0) printf ("Assertion failed: " "ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 257, GF_LOG_ERROR, "Assertion failed: " "ctx" ); } while (0); } } while (0); | |||
258 | ||||
259 | rsp.op_errno = GF_PROBE_FRIEND; | |||
260 | if (ctx->req) { | |||
261 | glusterd_xfer_cli_probe_resp (ctx->req, rsp.op_ret, | |||
262 | rsp.op_errno, | |||
263 | rsp.op_errstr, | |||
264 | ctx->hostname, ctx->port); | |||
265 | } | |||
266 | ||||
267 | glusterd_destroy_probe_ctx (ctx); | |||
268 | (void) glusterd_friend_remove (NULL((void*)0), rsp.hostname); | |||
269 | ret = rsp.op_ret; | |||
270 | goto out; | |||
271 | } | |||
272 | ||||
273 | uuid_copy (peerinfo->uuid, rsp.uuid); | |||
274 | ||||
275 | ret = glusterd_friend_sm_new_event | |||
276 | (GD_FRIEND_EVENT_INIT_FRIEND_REQ, &event); | |||
277 | ||||
278 | if (ret) { | |||
279 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 280 , GF_LOG_ERROR, "Unable to get event"); } while (0) | |||
280 | "Unable to get event")do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 280 , GF_LOG_ERROR, "Unable to get event"); } while (0); | |||
281 | goto out; | |||
282 | } | |||
283 | ||||
284 | event->peerinfo = peerinfo; | |||
285 | event->ctx = ((call_frame_t *)myframe)->local; | |||
286 | ((call_frame_t *)myframe)->local = NULL((void*)0); | |||
287 | ret = glusterd_friend_sm_inject_event (event); | |||
288 | ||||
289 | ||||
290 | if (!ret) { | |||
291 | glusterd_friend_sm (); | |||
292 | glusterd_op_sm (); | |||
293 | } | |||
294 | ||||
295 | gf_log ("glusterd", GF_LOG_INFO, "Received resp to probe req")do { do { if (0) printf ("Received resp to probe req"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__ , 295, GF_LOG_INFO, "Received resp to probe req"); } while (0 ); | |||
296 | ||||
297 | out: | |||
298 | free (rsp.hostname);//malloced by xdr | |||
299 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
300 | return ret; | |||
301 | } | |||
302 | ||||
303 | int | |||
304 | glusterd_probe_cbk (struct rpc_req *req, struct iovec *iov, | |||
305 | int count, void *myframe) | |||
306 | { | |||
307 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
308 | __glusterd_probe_cbk); | |||
309 | } | |||
310 | ||||
311 | ||||
312 | int | |||
313 | __glusterd_friend_add_cbk (struct rpc_req * req, struct iovec *iov, | |||
314 | int count, void *myframe) | |||
315 | { | |||
316 | gd1_mgmt_friend_rsp rsp = {{0},}; | |||
317 | int ret = -1; | |||
318 | glusterd_friend_sm_event_t *event = NULL((void*)0); | |||
319 | glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE; | |||
320 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
321 | int32_t op_ret = -1; | |||
322 | int32_t op_errno = -1; | |||
323 | glusterd_probe_ctx_t *ctx = NULL((void*)0); | |||
324 | glusterd_friend_update_ctx_t *ev_ctx = NULL((void*)0); | |||
325 | ||||
326 | if (-1 == req->rpc_status) { | |||
327 | rsp.op_ret = -1; | |||
328 | rsp.op_errno = EINVAL22; | |||
329 | goto out; | |||
330 | } | |||
331 | ||||
332 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); | |||
333 | if (ret < 0) { | |||
334 | gf_log ("", GF_LOG_ERROR, "error")do { do { if (0) printf ("error"); } while (0); _gf_log ("", "glusterd-rpc-ops.c" , __FUNCTION__, 334, GF_LOG_ERROR, "error"); } while (0); | |||
335 | rsp.op_ret = -1; | |||
336 | rsp.op_errno = EINVAL22; | |||
337 | goto out; | |||
338 | } | |||
339 | ||||
340 | op_ret = rsp.op_ret; | |||
341 | op_errno = rsp.op_errno; | |||
342 | ||||
343 | gf_log ("glusterd", GF_LOG_INFO,do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 345, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0) | |||
344 | "Received %s from uuid: %s, host: %s, port: %d",do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 345, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0) | |||
345 | (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port)do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 345, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); | |||
346 | ||||
347 | ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); | |||
348 | ||||
349 | if (ret) { | |||
350 | gf_log ("", GF_LOG_ERROR, "received friend add response from"do { do { if (0) printf ("received friend add response from" " unknown peer uuid: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log ("", "glusterd-rpc-ops.c" , __FUNCTION__, 351, GF_LOG_ERROR, "received friend add response from" " unknown peer uuid: %s", uuid_utoa (rsp.uuid)); } while (0) | |||
351 | " unknown peer uuid: %s", uuid_utoa (rsp.uuid))do { do { if (0) printf ("received friend add response from" " unknown peer uuid: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log ("", "glusterd-rpc-ops.c" , __FUNCTION__, 351, GF_LOG_ERROR, "received friend add response from" " unknown peer uuid: %s", uuid_utoa (rsp.uuid)); } while (0); | |||
352 | goto out; | |||
353 | } | |||
354 | ||||
355 | if (op_ret) | |||
356 | event_type = GD_FRIEND_EVENT_RCVD_RJT; | |||
357 | else | |||
358 | event_type = GD_FRIEND_EVENT_RCVD_ACC; | |||
359 | ||||
360 | ret = glusterd_friend_sm_new_event (event_type, &event); | |||
361 | ||||
362 | if (ret) { | |||
363 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 364 , GF_LOG_ERROR, "Unable to get event"); } while (0) | |||
364 | "Unable to get event")do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 364 , GF_LOG_ERROR, "Unable to get event"); } while (0); | |||
365 | goto out; | |||
366 | } | |||
367 | event->peerinfo = peerinfo; | |||
368 | ev_ctx = GF_CALLOC (1, sizeof (*ev_ctx),__gf_calloc (1, sizeof (*ev_ctx), gf_gld_mt_friend_update_ctx_t ) | |||
369 | gf_gld_mt_friend_update_ctx_t)__gf_calloc (1, sizeof (*ev_ctx), gf_gld_mt_friend_update_ctx_t ); | |||
370 | if (!ev_ctx) { | |||
371 | ret = -1; | |||
372 | goto out; | |||
373 | } | |||
374 | ||||
375 | uuid_copy (ev_ctx->uuid, rsp.uuid); | |||
376 | ev_ctx->hostname = gf_strdup (rsp.hostname); | |||
377 | ||||
378 | event->ctx = ev_ctx; | |||
379 | ret = glusterd_friend_sm_inject_event (event); | |||
380 | ||||
381 | if (ret) | |||
382 | goto out; | |||
383 | ||||
384 | out: | |||
385 | ctx = ((call_frame_t *)myframe)->local; | |||
386 | ((call_frame_t *)myframe)->local = NULL((void*)0); | |||
387 | ||||
388 | GF_ASSERT (ctx)do { if (!(ctx)) { do { do { if (0) printf ("Assertion failed: " "ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 388, GF_LOG_ERROR, "Assertion failed: " "ctx" ); } while (0); } } while (0); | |||
389 | ||||
390 | if (ctx->req)//reverse probe doesn't have req | |||
391 | ret = glusterd_xfer_cli_probe_resp (ctx->req, op_ret, op_errno, | |||
392 | NULL((void*)0), ctx->hostname, | |||
393 | ctx->port); | |||
394 | if (!ret) { | |||
395 | glusterd_friend_sm (); | |||
396 | glusterd_op_sm (); | |||
397 | } | |||
398 | if (ctx) | |||
399 | glusterd_destroy_probe_ctx (ctx); | |||
400 | free (rsp.hostname);//malloced by xdr | |||
401 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
402 | return ret; | |||
403 | } | |||
404 | ||||
405 | int | |||
406 | glusterd_friend_add_cbk (struct rpc_req *req, struct iovec *iov, | |||
407 | int count, void *myframe) | |||
408 | { | |||
409 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
410 | __glusterd_friend_add_cbk); | |||
411 | } | |||
412 | ||||
413 | int | |||
414 | __glusterd_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, | |||
415 | int count, void *myframe) | |||
416 | { | |||
417 | gd1_mgmt_friend_rsp rsp = {{0},}; | |||
418 | glusterd_conf_t *conf = NULL((void*)0); | |||
419 | int ret = -1; | |||
420 | glusterd_friend_sm_event_t *event = NULL((void*)0); | |||
421 | glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE; | |||
422 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
423 | int32_t op_ret = -1; | |||
424 | int32_t op_errno = -1; | |||
425 | glusterd_probe_ctx_t *ctx = NULL((void*)0); | |||
426 | gf_boolean_t move_sm_now = _gf_true; | |||
427 | ||||
428 | conf = THIS(*__glusterfs_this_location())->private; | |||
429 | GF_ASSERT (conf)do { if (!(conf)) { do { do { if (0) printf ("Assertion failed: " "conf"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 429, GF_LOG_ERROR, "Assertion failed: " "conf" ); } while (0); } } while (0); | |||
430 | ||||
431 | ctx = ((call_frame_t *)myframe)->local; | |||
| ||||
432 | ((call_frame_t *)myframe)->local = NULL((void*)0); | |||
433 | GF_ASSERT (ctx)do { if (!(ctx)) { do { do { if (0) printf ("Assertion failed: " "ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 433, GF_LOG_ERROR, "Assertion failed: " "ctx" ); } while (0); } } while (0); | |||
434 | ||||
435 | if (-1 == req->rpc_status) { | |||
436 | rsp.op_ret = -1; | |||
437 | rsp.op_errno = EINVAL22; | |||
438 | move_sm_now = _gf_false; | |||
439 | goto inject; | |||
440 | } | |||
441 | ||||
442 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); | |||
443 | if (ret < 0) { | |||
444 | gf_log ("", GF_LOG_ERROR, "error")do { do { if (0) printf ("error"); } while (0); _gf_log ("", "glusterd-rpc-ops.c" , __FUNCTION__, 444, GF_LOG_ERROR, "error"); } while (0); | |||
445 | rsp.op_ret = -1; | |||
446 | rsp.op_errno = EINVAL22; | |||
447 | goto respond; | |||
448 | } | |||
449 | ||||
450 | op_ret = rsp.op_ret; | |||
451 | op_errno = rsp.op_errno; | |||
452 | ||||
453 | gf_log ("glusterd", GF_LOG_INFO,do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 455, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0) | |||
454 | "Received %s from uuid: %s, host: %s, port: %d",do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 455, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0) | |||
455 | (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp.port)do { do { if (0) printf ("Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c" , __FUNCTION__, 455, GF_LOG_INFO, "Received %s from uuid: %s, host: %s, port: %d" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid), rsp.hostname, rsp .port); } while (0); | |||
456 | ||||
457 | inject: | |||
458 | ret = glusterd_friend_find (rsp.uuid, ctx->hostname, &peerinfo); | |||
459 | ||||
460 | if (ret) { | |||
461 | //can happen as part of rpc clnt connection cleanup | |||
462 | //when the frame timeout happens after 30 minutes | |||
463 | goto respond; | |||
464 | } | |||
465 | ||||
466 | event_type = GD_FRIEND_EVENT_REMOVE_FRIEND; | |||
467 | ||||
468 | ret = glusterd_friend_sm_new_event (event_type, &event); | |||
469 | ||||
470 | if (ret) { | |||
471 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 472 , GF_LOG_ERROR, "Unable to get event"); } while (0) | |||
472 | "Unable to get event")do { do { if (0) printf ("Unable to get event"); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 472 , GF_LOG_ERROR, "Unable to get event"); } while (0); | |||
473 | goto respond; | |||
474 | } | |||
475 | event->peerinfo = peerinfo; | |||
476 | ||||
477 | ret = glusterd_friend_sm_inject_event (event); | |||
478 | ||||
479 | if (ret) | |||
480 | goto respond; | |||
481 | ||||
482 | /*friend_sm would be moved on CLNT_DISCONNECT, consequently | |||
483 | cleaning up peerinfo. Else, we run the risk of triggering | |||
484 | a clnt_destroy within saved_frames_unwind. | |||
485 | */ | |||
486 | op_ret = 0; | |||
487 | ||||
488 | ||||
489 | respond: | |||
490 | ret = glusterd_xfer_cli_deprobe_resp (ctx->req, op_ret, op_errno, NULL((void*)0), | |||
| ||||
491 | ctx->hostname); | |||
492 | if (!ret && move_sm_now) { | |||
493 | glusterd_friend_sm (); | |||
494 | glusterd_op_sm (); | |||
495 | } | |||
496 | ||||
497 | if (ctx) { | |||
498 | glusterd_broadcast_friend_delete (ctx->hostname, NULL((void*)0)); | |||
499 | glusterd_destroy_probe_ctx (ctx); | |||
500 | } | |||
501 | ||||
502 | free (rsp.hostname);//malloced by xdr | |||
503 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
504 | return ret; | |||
505 | } | |||
506 | ||||
507 | int | |||
508 | glusterd_friend_remove_cbk (struct rpc_req *req, struct iovec *iov, | |||
509 | int count, void *myframe) | |||
510 | { | |||
511 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
512 | __glusterd_friend_remove_cbk); | |||
513 | } | |||
514 | ||||
515 | int32_t | |||
516 | __glusterd_friend_update_cbk (struct rpc_req *req, struct iovec *iov, | |||
517 | int count, void *myframe) | |||
518 | { | |||
519 | int ret = -1; | |||
520 | gd1_mgmt_friend_update_rsp rsp = {{0}, }; | |||
521 | xlator_t *this = NULL((void*)0); | |||
522 | ||||
523 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 523, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
524 | this = THIS(*__glusterfs_this_location()); | |||
525 | ||||
526 | if (-1 == req->rpc_status) { | |||
527 | gf_log (this->name, GF_LOG_ERROR, "RPC Error")do { do { if (0) printf ("RPC Error"); } while (0); _gf_log ( this->name, "glusterd-rpc-ops.c", __FUNCTION__, 527, GF_LOG_ERROR , "RPC Error"); } while (0); | |||
528 | goto out; | |||
529 | } | |||
530 | ||||
531 | ret = xdr_to_generic (*iov, &rsp, | |||
532 | (xdrproc_t)xdr_gd1_mgmt_friend_update_rsp); | |||
533 | if (ret < 0) { | |||
534 | gf_log (this->name, GF_LOG_ERROR, "Failed to serialize friend"do { do { if (0) printf ("Failed to serialize friend" " update repsonse" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 535, GF_LOG_ERROR, "Failed to serialize friend" " update repsonse"); } while (0) | |||
535 | " update repsonse")do { do { if (0) printf ("Failed to serialize friend" " update repsonse" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 535, GF_LOG_ERROR, "Failed to serialize friend" " update repsonse"); } while (0); | |||
536 | goto out; | |||
537 | } | |||
538 | ||||
539 | ret = 0; | |||
540 | out: | |||
541 | gf_log (this->name, GF_LOG_INFO, "Received %s from uuid: %s",do { do { if (0) printf ("Received %s from uuid: %s", (ret)?"RJT" :"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this-> name, "glusterd-rpc-ops.c", __FUNCTION__, 542, GF_LOG_INFO, "Received %s from uuid: %s" , (ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0) | |||
542 | (ret)?"RJT":"ACC", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Received %s from uuid: %s", (ret)?"RJT" :"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this-> name, "glusterd-rpc-ops.c", __FUNCTION__, 542, GF_LOG_INFO, "Received %s from uuid: %s" , (ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); | |||
543 | ||||
544 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
545 | return ret; | |||
546 | } | |||
547 | ||||
548 | int | |||
549 | glusterd_friend_update_cbk (struct rpc_req *req, struct iovec *iov, | |||
550 | int count, void *myframe) | |||
551 | { | |||
552 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
553 | __glusterd_friend_update_cbk); | |||
554 | } | |||
555 | ||||
556 | int32_t | |||
557 | __glusterd_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, | |||
558 | int count, void *myframe) | |||
559 | { | |||
560 | gd1_mgmt_cluster_lock_rsp rsp = {{0},}; | |||
561 | int ret = -1; | |||
562 | int32_t op_ret = -1; | |||
563 | glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; | |||
564 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
565 | xlator_t *this = NULL((void*)0); | |||
566 | ||||
567 | this = THIS(*__glusterfs_this_location()); | |||
568 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 568, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
569 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 569, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
570 | ||||
571 | if (-1 == req->rpc_status) { | |||
572 | rsp.op_ret = -1; | |||
573 | rsp.op_errno = EINVAL22; | |||
574 | goto out; | |||
575 | } | |||
576 | ||||
577 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); | |||
578 | if (ret < 0) { | |||
579 | gf_log (this->name, GF_LOG_ERROR, "Failed to decode lock "do { do { if (0) printf ("Failed to decode lock " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 580, GF_LOG_ERROR, "Failed to decode lock " "response received from peer" ); } while (0) | |||
580 | "response received from peer")do { do { if (0) printf ("Failed to decode lock " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 580, GF_LOG_ERROR, "Failed to decode lock " "response received from peer" ); } while (0); | |||
581 | rsp.op_ret = -1; | |||
582 | rsp.op_errno = EINVAL22; | |||
583 | goto out; | |||
584 | } | |||
585 | ||||
586 | out: | |||
587 | op_ret = rsp.op_ret; | |||
588 | ||||
589 | gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG,do { do { if (0) printf ("Received lock %s from uuid: %s", (op_ret ) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 591, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received lock %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ) | |||
590 | "Received lock %s from uuid: %s", (op_ret) ? "RJT" : "ACC",do { do { if (0) printf ("Received lock %s from uuid: %s", (op_ret ) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 591, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received lock %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ) | |||
591 | uuid_utoa (rsp.uuid))do { do { if (0) printf ("Received lock %s from uuid: %s", (op_ret ) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 591, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received lock %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ); | |||
592 | ||||
593 | ret = glusterd_friend_find (rsp.uuid, NULL((void*)0), &peerinfo); | |||
594 | ||||
595 | if (ret) { | |||
596 | gf_log (this->name, GF_LOG_CRITICAL, "Lock response received "do { do { if (0) printf ("Lock response received " "from unknown peer: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 597, GF_LOG_CRITICAL, "Lock response received " "from unknown peer: %s", uuid_utoa (rsp.uuid)); } while (0) | |||
597 | "from unknown peer: %s", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Lock response received " "from unknown peer: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 597, GF_LOG_CRITICAL, "Lock response received " "from unknown peer: %s", uuid_utoa (rsp.uuid)); } while (0); | |||
598 | } | |||
599 | ||||
600 | if (op_ret) { | |||
601 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
602 | opinfo.op_ret = op_ret; | |||
603 | opinfo.op_errstr = gf_strdup ("Another transaction could be in " | |||
604 | "progress. Please try again after" | |||
605 | " sometime."); | |||
606 | } else { | |||
607 | event_type = GD_OP_EVENT_RCVD_ACC; | |||
608 | } | |||
609 | ||||
610 | ret = glusterd_op_sm_inject_event (event_type, NULL((void*)0)); | |||
611 | ||||
612 | if (!ret) { | |||
613 | glusterd_friend_sm (); | |||
614 | glusterd_op_sm (); | |||
615 | } | |||
616 | ||||
617 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
618 | return ret; | |||
619 | } | |||
620 | ||||
621 | int32_t | |||
622 | glusterd_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, | |||
623 | int count, void *myframe) | |||
624 | { | |||
625 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
626 | __glusterd_cluster_lock_cbk); | |||
627 | } | |||
628 | ||||
629 | int32_t | |||
630 | __glusterd_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, | |||
631 | int count, void *myframe) | |||
632 | { | |||
633 | gd1_mgmt_cluster_lock_rsp rsp = {{0},}; | |||
634 | int ret = -1; | |||
635 | int32_t op_ret = -1; | |||
636 | glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; | |||
637 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
638 | xlator_t *this = NULL((void*)0); | |||
639 | ||||
640 | this = THIS(*__glusterfs_this_location()); | |||
641 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 641, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
642 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 642, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
643 | ||||
644 | if (-1 == req->rpc_status) { | |||
645 | rsp.op_ret = -1; | |||
646 | rsp.op_errno = EINVAL22; | |||
647 | goto out; | |||
648 | } | |||
649 | ||||
650 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp); | |||
651 | if (ret < 0) { | |||
652 | gf_log (this->name, GF_LOG_ERROR, "Failed to decode unlock "do { do { if (0) printf ("Failed to decode unlock " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 653, GF_LOG_ERROR, "Failed to decode unlock " "response received from peer" ); } while (0) | |||
653 | "response received from peer")do { do { if (0) printf ("Failed to decode unlock " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 653, GF_LOG_ERROR, "Failed to decode unlock " "response received from peer" ); } while (0); | |||
654 | rsp.op_ret = -1; | |||
655 | rsp.op_errno = EINVAL22; | |||
656 | goto out; | |||
657 | } | |||
658 | ||||
659 | out: | |||
660 | op_ret = rsp.op_ret; | |||
661 | ||||
662 | gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG,do { do { if (0) printf ("Received unlock %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 664, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received unlock %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0) | |||
663 | "Received unlock %s from uuid: %s",do { do { if (0) printf ("Received unlock %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 664, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received unlock %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0) | |||
664 | (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Received unlock %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 664, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received unlock %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); | |||
665 | ||||
666 | ret = glusterd_friend_find (rsp.uuid, NULL((void*)0), &peerinfo); | |||
667 | ||||
668 | if (ret) { | |||
669 | gf_log (this->name, GF_LOG_CRITICAL, "Unlock response received "do { do { if (0) printf ("Unlock response received " "from unknown peer %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 670, GF_LOG_CRITICAL, "Unlock response received " "from unknown peer %s", uuid_utoa (rsp.uuid)); } while (0) | |||
670 | "from unknown peer %s", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Unlock response received " "from unknown peer %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 670, GF_LOG_CRITICAL, "Unlock response received " "from unknown peer %s", uuid_utoa (rsp.uuid)); } while (0); | |||
671 | } | |||
672 | ||||
673 | if (op_ret) { | |||
674 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
675 | opinfo.op_ret = op_ret; | |||
676 | } else { | |||
677 | event_type = GD_OP_EVENT_RCVD_ACC; | |||
678 | } | |||
679 | ||||
680 | ret = glusterd_op_sm_inject_event (event_type, NULL((void*)0)); | |||
681 | ||||
682 | if (!ret) { | |||
683 | glusterd_friend_sm (); | |||
684 | glusterd_op_sm (); | |||
685 | } | |||
686 | ||||
687 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
688 | return ret; | |||
689 | } | |||
690 | ||||
691 | int32_t | |||
692 | glusterd_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, | |||
693 | int count, void *myframe) | |||
694 | { | |||
695 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
696 | __glusterd_cluster_unlock_cbk); | |||
697 | } | |||
698 | ||||
699 | int32_t | |||
700 | __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
701 | int count, void *myframe) | |||
702 | { | |||
703 | gd1_mgmt_stage_op_rsp rsp = {{0},}; | |||
704 | int ret = -1; | |||
705 | int32_t op_ret = -1; | |||
706 | glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; | |||
707 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
708 | dict_t *dict = NULL((void*)0); | |||
709 | char err_str[2048] = {0}; | |||
710 | char *peer_str = NULL((void*)0); | |||
711 | xlator_t *this = NULL((void*)0); | |||
712 | ||||
713 | this = THIS(*__glusterfs_this_location()); | |||
714 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 714, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
715 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 715, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
716 | ||||
717 | if (-1 == req->rpc_status) { | |||
718 | rsp.op_ret = -1; | |||
719 | rsp.op_errno = EINVAL22; | |||
720 | /* use standard allocation because to keep uniformity | |||
721 | in freeing it */ | |||
722 | rsp.op_errstr = strdup ("error"); | |||
723 | goto out; | |||
724 | } | |||
725 | ||||
726 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); | |||
727 | if (ret < 0) { | |||
728 | gf_log (this->name, GF_LOG_ERROR, "Failed to decode stage "do { do { if (0) printf ("Failed to decode stage " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 729, GF_LOG_ERROR, "Failed to decode stage " "response received from peer" ); } while (0) | |||
729 | "response received from peer")do { do { if (0) printf ("Failed to decode stage " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 729, GF_LOG_ERROR, "Failed to decode stage " "response received from peer" ); } while (0); | |||
730 | rsp.op_ret = -1; | |||
731 | rsp.op_errno = EINVAL22; | |||
732 | /* use standard allocation because to keep uniformity | |||
733 | in freeing it */ | |||
734 | rsp.op_errstr = strdup ("Failed to decode stage response " | |||
735 | "received from peer."); | |||
736 | goto out; | |||
737 | } | |||
738 | ||||
739 | if (rsp.dict.dict_len) { | |||
740 | /* Unserialize the dictionary */ | |||
741 | dict = dict_new (); | |||
742 | ||||
743 | ret = dict_unserialize (rsp.dict.dict_val, | |||
744 | rsp.dict.dict_len, | |||
745 | &dict); | |||
746 | if (ret < 0) { | |||
747 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 749, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0) | |||
748 | "failed to "do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 749, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0) | |||
749 | "unserialize rsp-buffer to dictionary")do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 749, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0); | |||
750 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
751 | goto out; | |||
752 | } else { | |||
753 | dict->extra_stdfree = rsp.dict.dict_val; | |||
754 | } | |||
755 | } | |||
756 | ||||
757 | out: | |||
758 | op_ret = rsp.op_ret; | |||
759 | ||||
760 | gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG,do { do { if (0) printf ("Received stage %s from uuid: %s", ( op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 762, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received stage %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ) | |||
761 | "Received stage %s from uuid: %s",do { do { if (0) printf ("Received stage %s from uuid: %s", ( op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 762, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received stage %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ) | |||
762 | (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Received stage %s from uuid: %s", ( op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 762, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received stage %s from uuid: %s" , (op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid)); } while (0 ); | |||
763 | ||||
764 | ret = glusterd_friend_find (rsp.uuid, NULL((void*)0), &peerinfo); | |||
765 | ||||
766 | if (ret) { | |||
767 | gf_log (this->name, GF_LOG_CRITICAL, "Stage response received "do { do { if (0) printf ("Stage response received " "from unknown peer: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 768, GF_LOG_CRITICAL, "Stage response received " "from unknown peer: %s", uuid_utoa (rsp.uuid)); } while (0) | |||
768 | "from unknown peer: %s", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Stage response received " "from unknown peer: %s" , uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 768, GF_LOG_CRITICAL, "Stage response received " "from unknown peer: %s", uuid_utoa (rsp.uuid)); } while (0); | |||
769 | } | |||
770 | ||||
771 | if (op_ret) { | |||
772 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
773 | opinfo.op_ret = op_ret; | |||
774 | if (strcmp ("", rsp.op_errstr)) { | |||
775 | opinfo.op_errstr = gf_strdup (rsp.op_errstr); | |||
776 | } else { | |||
777 | if (peerinfo) | |||
778 | peer_str = peerinfo->hostname; | |||
779 | else | |||
780 | peer_str = uuid_utoa (rsp.uuid); | |||
781 | snprintf (err_str, sizeof (err_str), | |||
782 | OPERRSTR_STAGE_FAIL"Staging failed on %s. Please check the log file " "for more details.", peer_str); | |||
783 | opinfo.op_errstr = gf_strdup (err_str); | |||
784 | } | |||
785 | if (!opinfo.op_errstr) { | |||
786 | ret = -1; | |||
787 | goto out; | |||
788 | } | |||
789 | } else { | |||
790 | event_type = GD_OP_EVENT_RCVD_ACC; | |||
791 | } | |||
792 | ||||
793 | switch (rsp.op) { | |||
794 | case GD_OP_REPLACE_BRICK: | |||
795 | glusterd_rb_use_rsp_dict (NULL((void*)0), dict); | |||
796 | break; | |||
797 | } | |||
798 | ||||
799 | ret = glusterd_op_sm_inject_event (event_type, NULL((void*)0)); | |||
800 | ||||
801 | if (!ret) { | |||
802 | glusterd_friend_sm (); | |||
803 | glusterd_op_sm (); | |||
804 | } | |||
805 | ||||
806 | free (rsp.op_errstr); //malloced by xdr | |||
807 | if (dict) { | |||
808 | if (!dict->extra_stdfree && rsp.dict.dict_val) | |||
809 | free (rsp.dict.dict_val); //malloced by xdr | |||
810 | dict_unref (dict); | |||
811 | } else { | |||
812 | free (rsp.dict.dict_val); //malloced by xdr | |||
813 | } | |||
814 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
815 | return ret; | |||
816 | } | |||
817 | ||||
818 | int32_t | |||
819 | glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
820 | int count, void *myframe) | |||
821 | { | |||
822 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
823 | __glusterd_stage_op_cbk); | |||
824 | } | |||
825 | ||||
826 | int32_t | |||
827 | __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
828 | int count, void *myframe) | |||
829 | { | |||
830 | gd1_mgmt_commit_op_rsp rsp = {{0},}; | |||
831 | int ret = -1; | |||
832 | int32_t op_ret = -1; | |||
833 | glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; | |||
834 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
835 | dict_t *dict = NULL((void*)0); | |||
836 | char err_str[2048] = {0}; | |||
837 | char *peer_str = NULL((void*)0); | |||
838 | xlator_t *this = NULL((void*)0); | |||
839 | ||||
840 | this = THIS(*__glusterfs_this_location()); | |||
841 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 841, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
842 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 842, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
843 | ||||
844 | if (-1 == req->rpc_status) { | |||
845 | rsp.op_ret = -1; | |||
846 | rsp.op_errno = EINVAL22; | |||
847 | /* use standard allocation because to keep uniformity | |||
848 | in freeing it */ | |||
849 | rsp.op_errstr = strdup ("error"); | |||
850 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
851 | goto out; | |||
852 | } | |||
853 | ||||
854 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); | |||
855 | if (ret < 0) { | |||
856 | gf_log (this->name, GF_LOG_ERROR, "Failed to decode commit "do { do { if (0) printf ("Failed to decode commit " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 857, GF_LOG_ERROR, "Failed to decode commit " "response received from peer" ); } while (0) | |||
857 | "response received from peer")do { do { if (0) printf ("Failed to decode commit " "response received from peer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 857, GF_LOG_ERROR, "Failed to decode commit " "response received from peer" ); } while (0); | |||
858 | rsp.op_ret = -1; | |||
859 | rsp.op_errno = EINVAL22; | |||
860 | /* use standard allocation because to keep uniformity | |||
861 | in freeing it */ | |||
862 | rsp.op_errstr = strdup ("Failed to decode commit response " | |||
863 | "received from peer."); | |||
864 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
865 | goto out; | |||
866 | } | |||
867 | ||||
868 | if (rsp.dict.dict_len) { | |||
869 | /* Unserialize the dictionary */ | |||
870 | dict = dict_new (); | |||
871 | ||||
872 | ret = dict_unserialize (rsp.dict.dict_val, | |||
873 | rsp.dict.dict_len, | |||
874 | &dict); | |||
875 | if (ret < 0) { | |||
876 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 878, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0) | |||
877 | "failed to "do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 878, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0) | |||
878 | "unserialize rsp-buffer to dictionary")do { do { if (0) printf ("failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 878, GF_LOG_ERROR, "failed to " "unserialize rsp-buffer to dictionary" ); } while (0); | |||
879 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
880 | goto out; | |||
881 | } else { | |||
882 | dict->extra_stdfree = rsp.dict.dict_val; | |||
883 | } | |||
884 | } | |||
885 | ||||
886 | op_ret = rsp.op_ret; | |||
887 | ||||
888 | gf_log (this->name, (op_ret) ? GF_LOG_ERROR : GF_LOG_DEBUG,do { do { if (0) printf ("Received commit %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 890, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received commit %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0) | |||
889 | "Received commit %s from uuid: %s",do { do { if (0) printf ("Received commit %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 890, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received commit %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0) | |||
890 | (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid))do { do { if (0) printf ("Received commit %s from uuid: %s", ( op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 890, (op_ret ) ? GF_LOG_ERROR : GF_LOG_DEBUG, "Received commit %s from uuid: %s" , (op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid)); } while (0); | |||
891 | ||||
892 | ret = glusterd_friend_find (rsp.uuid, NULL((void*)0), &peerinfo); | |||
893 | ||||
894 | if (ret) { | |||
895 | gf_log (this->name, GF_LOG_CRITICAL, "Commit response for "do { do { if (0) printf ("Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 897, GF_LOG_CRITICAL , "Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0) | |||
896 | "'Volume %s' received from unknown peer: %s",do { do { if (0) printf ("Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 897, GF_LOG_CRITICAL , "Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0) | |||
897 | gd_op_list[opinfo.op], uuid_utoa (rsp.uuid))do { do { if (0) printf ("Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 897, GF_LOG_CRITICAL , "Commit response for " "'Volume %s' received from unknown peer: %s" , gd_op_list[opinfo.op], uuid_utoa (rsp.uuid)); } while (0); | |||
898 | } | |||
899 | ||||
900 | if (op_ret) { | |||
901 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
902 | opinfo.op_ret = op_ret; | |||
903 | if (strcmp ("", rsp.op_errstr)) { | |||
904 | opinfo.op_errstr = gf_strdup(rsp.op_errstr); | |||
905 | } else { | |||
906 | if (peerinfo) | |||
907 | peer_str = peerinfo->hostname; | |||
908 | else | |||
909 | peer_str = uuid_utoa (rsp.uuid); | |||
910 | snprintf (err_str, sizeof (err_str), | |||
911 | OPERRSTR_COMMIT_FAIL"Commit failed on %s. Please check the log file " "for more details.", peer_str); | |||
912 | opinfo.op_errstr = gf_strdup (err_str); | |||
913 | } | |||
914 | if (!opinfo.op_errstr) { | |||
915 | ret = -1; | |||
916 | goto out; | |||
917 | } | |||
918 | } else { | |||
919 | event_type = GD_OP_EVENT_RCVD_ACC; | |||
920 | switch (rsp.op) { | |||
921 | case GD_OP_REPLACE_BRICK: | |||
922 | ret = glusterd_rb_use_rsp_dict (NULL((void*)0), dict); | |||
923 | if (ret) | |||
924 | goto out; | |||
925 | break; | |||
926 | ||||
927 | case GD_OP_SYNC_VOLUME: | |||
928 | ret = glusterd_sync_use_rsp_dict (NULL((void*)0), dict); | |||
929 | if (ret) | |||
930 | goto out; | |||
931 | break; | |||
932 | ||||
933 | case GD_OP_PROFILE_VOLUME: | |||
934 | ret = glusterd_profile_volume_use_rsp_dict (NULL((void*)0), dict); | |||
935 | if (ret) | |||
936 | goto out; | |||
937 | break; | |||
938 | ||||
939 | case GD_OP_GSYNC_SET: | |||
940 | ret = glusterd_gsync_use_rsp_dict (NULL((void*)0), dict, rsp.op_errstr); | |||
941 | if (ret) | |||
942 | goto out; | |||
943 | break; | |||
944 | ||||
945 | case GD_OP_STATUS_VOLUME: | |||
946 | ret = glusterd_volume_status_copy_to_op_ctx_dict (NULL((void*)0), dict); | |||
947 | if (ret) | |||
948 | goto out; | |||
949 | break; | |||
950 | ||||
951 | case GD_OP_REBALANCE: | |||
952 | case GD_OP_DEFRAG_BRICK_VOLUME: | |||
953 | ret = glusterd_volume_rebalance_use_rsp_dict (NULL((void*)0), dict); | |||
954 | if (ret) | |||
955 | goto out; | |||
956 | break; | |||
957 | ||||
958 | case GD_OP_HEAL_VOLUME: | |||
959 | ret = glusterd_volume_heal_use_rsp_dict (NULL((void*)0), dict); | |||
960 | if (ret) | |||
961 | goto out; | |||
962 | ||||
963 | break; | |||
964 | ||||
965 | default: | |||
966 | break; | |||
967 | } | |||
968 | } | |||
969 | ||||
970 | out: | |||
971 | ret = glusterd_op_sm_inject_event (event_type, NULL((void*)0)); | |||
972 | ||||
973 | if (!ret) { | |||
974 | glusterd_friend_sm (); | |||
975 | glusterd_op_sm (); | |||
976 | } | |||
977 | ||||
978 | if (dict) | |||
979 | dict_unref (dict); | |||
980 | free (rsp.op_errstr); //malloced by xdr | |||
981 | GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe))do { ((call_frame_t *)myframe)->local = ((void*)0); STACK_DESTROY (((call_frame_t *)myframe)->root); } while (0); | |||
982 | return ret; | |||
983 | } | |||
984 | ||||
985 | int32_t | |||
986 | glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
987 | int count, void *myframe) | |||
988 | { | |||
989 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
990 | __glusterd_commit_op_cbk); | |||
991 | } | |||
992 | ||||
993 | int32_t | |||
994 | glusterd_rpc_probe (call_frame_t *frame, xlator_t *this, | |||
995 | void *data) | |||
996 | { | |||
997 | gd1_mgmt_probe_req req = {{0},}; | |||
998 | int ret = 0; | |||
999 | int port = 0; | |||
1000 | char *hostname = NULL((void*)0); | |||
1001 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1002 | glusterd_conf_t *priv = NULL((void*)0); | |||
1003 | dict_t *dict = NULL((void*)0); | |||
1004 | ||||
1005 | if (!frame || !this || !data) { | |||
1006 | ret = -1; | |||
1007 | goto out; | |||
1008 | } | |||
1009 | ||||
1010 | dict = data; | |||
1011 | priv = this->private; | |||
1012 | ||||
1013 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1013, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1014 | ret = dict_get_str (dict, "hostname", &hostname); | |||
1015 | if (ret) | |||
1016 | goto out; | |||
1017 | ret = dict_get_int32 (dict, "port", &port); | |||
1018 | if (ret) | |||
1019 | port = GF_DEFAULT_BASE_PORT24007; | |||
1020 | ||||
1021 | ret = dict_get_ptr (dict, "peerinfo", VOID (&peerinfo)((void **) ((void *) &peerinfo))); | |||
1022 | if (ret) | |||
1023 | goto out; | |||
1024 | ||||
1025 | uuid_copy (req.uuid, MY_UUID(__glusterd_uuid())); | |||
1026 | req.hostname = gf_strdup (hostname); | |||
1027 | req.port = port; | |||
1028 | ||||
1029 | ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->peer, | |||
1030 | GLUSTERD_PROBE_QUERY, | |||
1031 | NULL((void*)0), this, glusterd_probe_cbk, | |||
1032 | (xdrproc_t)xdr_gd1_mgmt_probe_req); | |||
1033 | ||||
1034 | out: | |||
1035 | GF_FREE (req.hostname)__gf_free (req.hostname); | |||
1036 | gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 1036, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1037 | return ret; | |||
1038 | } | |||
1039 | ||||
1040 | ||||
1041 | int32_t | |||
1042 | glusterd_rpc_friend_add (call_frame_t *frame, xlator_t *this, | |||
1043 | void *data) | |||
1044 | { | |||
1045 | gd1_mgmt_friend_req req = {{0},}; | |||
1046 | int ret = 0; | |||
1047 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1048 | glusterd_conf_t *priv = NULL((void*)0); | |||
1049 | glusterd_friend_sm_event_t *event = NULL((void*)0); | |||
1050 | dict_t *vols = NULL((void*)0); | |||
1051 | ||||
1052 | ||||
1053 | if (!frame || !this || !data) { | |||
1054 | ret = -1; | |||
1055 | goto out; | |||
1056 | } | |||
1057 | ||||
1058 | event = data; | |||
1059 | priv = this->private; | |||
1060 | ||||
1061 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1061, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1062 | ||||
1063 | peerinfo = event->peerinfo; | |||
1064 | ||||
1065 | ret = glusterd_build_volume_dict (&vols); | |||
1066 | if (ret) | |||
1067 | goto out; | |||
1068 | ||||
1069 | uuid_copy (req.uuid, MY_UUID(__glusterd_uuid())); | |||
1070 | req.hostname = peerinfo->hostname; | |||
1071 | req.port = peerinfo->port; | |||
1072 | ||||
1073 | ret = dict_allocate_and_serialize (vols, &req.vols.vols_val, | |||
1074 | &req.vols.vols_len); | |||
1075 | if (ret) | |||
1076 | goto out; | |||
1077 | ||||
1078 | ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->peer, | |||
1079 | GLUSTERD_FRIEND_ADD, | |||
1080 | NULL((void*)0), this, glusterd_friend_add_cbk, | |||
1081 | (xdrproc_t)xdr_gd1_mgmt_friend_req); | |||
1082 | ||||
1083 | ||||
1084 | out: | |||
1085 | GF_FREE (req.vols.vols_val)__gf_free (req.vols.vols_val); | |||
1086 | ||||
1087 | if (vols) | |||
1088 | dict_unref (vols); | |||
1089 | ||||
1090 | gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 1090, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1091 | return ret; | |||
1092 | } | |||
1093 | ||||
1094 | int32_t | |||
1095 | glusterd_rpc_friend_remove (call_frame_t *frame, xlator_t *this, | |||
1096 | void *data) | |||
1097 | { | |||
1098 | gd1_mgmt_friend_req req = {{0},}; | |||
1099 | int ret = 0; | |||
1100 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1101 | glusterd_conf_t *priv = NULL((void*)0); | |||
1102 | glusterd_friend_sm_event_t *event = NULL((void*)0); | |||
1103 | ||||
1104 | if (!frame || !this || !data) { | |||
1105 | ret = -1; | |||
1106 | goto out; | |||
1107 | } | |||
1108 | ||||
1109 | event = data; | |||
1110 | priv = this->private; | |||
1111 | ||||
1112 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1112, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1113 | ||||
1114 | peerinfo = event->peerinfo; | |||
1115 | ||||
1116 | uuid_copy (req.uuid, MY_UUID(__glusterd_uuid())); | |||
1117 | req.hostname = peerinfo->hostname; | |||
1118 | req.port = peerinfo->port; | |||
1119 | ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->peer, | |||
1120 | GLUSTERD_FRIEND_REMOVE, NULL((void*)0), | |||
1121 | this, glusterd_friend_remove_cbk, | |||
1122 | (xdrproc_t)xdr_gd1_mgmt_friend_req); | |||
1123 | ||||
1124 | out: | |||
1125 | gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 1125, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1126 | return ret; | |||
1127 | } | |||
1128 | ||||
1129 | ||||
1130 | int32_t | |||
1131 | glusterd_rpc_friend_update (call_frame_t *frame, xlator_t *this, | |||
1132 | void *data) | |||
1133 | { | |||
1134 | gd1_mgmt_friend_update req = {{0},}; | |||
1135 | int ret = 0; | |||
1136 | glusterd_conf_t *priv = NULL((void*)0); | |||
1137 | dict_t *friends = NULL((void*)0); | |||
1138 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1139 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1140 | ||||
1141 | priv = this->private; | |||
1142 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1142, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1143 | ||||
1144 | friends = data; | |||
1145 | if (!friends) | |||
1146 | goto out; | |||
1147 | ||||
1148 | ret = dict_get_ptr (friends, "peerinfo", VOID(&peerinfo)((void **) ((void *) &peerinfo))); | |||
1149 | if (ret) | |||
1150 | goto out; | |||
1151 | ||||
1152 | ret = dict_allocate_and_serialize (friends, &req.friends.friends_val, | |||
1153 | &req.friends.friends_len); | |||
1154 | if (ret) | |||
1155 | goto out; | |||
1156 | ||||
1157 | uuid_copy (req.uuid, MY_UUID(__glusterd_uuid())); | |||
1158 | ||||
1159 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1160 | ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, | |||
1161 | peerinfo->peer, | |||
1162 | GLUSTERD_FRIEND_UPDATE, NULL((void*)0), | |||
1163 | this, glusterd_friend_update_cbk, | |||
1164 | (xdrproc_t)xdr_gd1_mgmt_friend_update); | |||
1165 | ||||
1166 | out: | |||
1167 | GF_FREE (req.friends.friends_val)__gf_free (req.friends.friends_val); | |||
1168 | ||||
1169 | gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("glusterd", "glusterd-rpc-ops.c", __FUNCTION__, 1169, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1170 | return ret; | |||
1171 | } | |||
1172 | ||||
1173 | int32_t | |||
1174 | glusterd_cluster_lock (call_frame_t *frame, xlator_t *this, | |||
1175 | void *data) | |||
1176 | { | |||
1177 | gd1_mgmt_cluster_lock_req req = {{0},}; | |||
1178 | int ret = -1; | |||
1179 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1180 | glusterd_conf_t *priv = NULL((void*)0); | |||
1181 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1182 | ||||
1183 | if (!this) | |||
1184 | goto out; | |||
1185 | ||||
1186 | peerinfo = data; | |||
1187 | ||||
1188 | priv = this->private; | |||
1189 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1189, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1190 | ||||
1191 | glusterd_get_uuid (&req.uuid); | |||
1192 | ||||
1193 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1194 | if (!dummy_frame) | |||
1195 | goto out; | |||
1196 | ||||
1197 | ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, | |||
1198 | peerinfo->mgmt, GLUSTERD_MGMT_CLUSTER_LOCK, | |||
1199 | NULL((void*)0), | |||
1200 | this, glusterd_cluster_lock_cbk, | |||
1201 | (xdrproc_t)xdr_gd1_mgmt_cluster_lock_req); | |||
1202 | out: | |||
1203 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1203, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1204 | return ret; | |||
1205 | } | |||
1206 | ||||
1207 | int32_t | |||
1208 | glusterd_cluster_unlock (call_frame_t *frame, xlator_t *this, | |||
1209 | void *data) | |||
1210 | { | |||
1211 | gd1_mgmt_cluster_lock_req req = {{0},}; | |||
1212 | int ret = -1; | |||
1213 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1214 | glusterd_conf_t *priv = NULL((void*)0); | |||
1215 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1216 | ||||
1217 | if (!this ) { | |||
1218 | ret = -1; | |||
1219 | goto out; | |||
1220 | } | |||
1221 | peerinfo = data; | |||
1222 | priv = this->private; | |||
1223 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1223, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1224 | ||||
1225 | glusterd_get_uuid (&req.uuid); | |||
1226 | ||||
1227 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1228 | if (!dummy_frame) | |||
1229 | goto out; | |||
1230 | ||||
1231 | ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, | |||
1232 | peerinfo->mgmt, GLUSTERD_MGMT_CLUSTER_UNLOCK, | |||
1233 | NULL((void*)0), | |||
1234 | this, glusterd_cluster_unlock_cbk, | |||
1235 | (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req); | |||
1236 | out: | |||
1237 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1237, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1238 | return ret; | |||
1239 | } | |||
1240 | ||||
1241 | int32_t | |||
1242 | glusterd_stage_op (call_frame_t *frame, xlator_t *this, | |||
1243 | void *data) | |||
1244 | { | |||
1245 | gd1_mgmt_stage_op_req req = {{0,},}; | |||
1246 | int ret = -1; | |||
1247 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1248 | glusterd_conf_t *priv = NULL((void*)0); | |||
1249 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1250 | dict_t *dict = NULL((void*)0); | |||
1251 | gf_boolean_t is_alloc = _gf_true; | |||
1252 | ||||
1253 | if (!this) { | |||
1254 | goto out; | |||
1255 | } | |||
1256 | ||||
1257 | dict = data; | |||
1258 | ||||
1259 | priv = this->private; | |||
1260 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1260, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1261 | ||||
1262 | ret = dict_get_ptr (dict, "peerinfo", VOID (&peerinfo)((void **) ((void *) &peerinfo))); | |||
1263 | if (ret) | |||
1264 | goto out; | |||
1265 | ||||
1266 | //peerinfo should not be in payload | |||
1267 | dict_del (dict, "peerinfo"); | |||
1268 | ||||
1269 | glusterd_get_uuid (&req.uuid); | |||
1270 | req.op = glusterd_op_get_op (); | |||
1271 | ||||
1272 | ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, | |||
1273 | &req.buf.buf_len); | |||
1274 | if (ret) { | |||
1275 | gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict "do { do { if (0) printf ("Failed to serialize dict " "to request buffer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1276, GF_LOG_ERROR, "Failed to serialize dict " "to request buffer"); } while (0) | |||
1276 | "to request buffer")do { do { if (0) printf ("Failed to serialize dict " "to request buffer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1276, GF_LOG_ERROR, "Failed to serialize dict " "to request buffer"); } while (0); | |||
1277 | goto out; | |||
1278 | } | |||
1279 | ||||
1280 | ||||
1281 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1282 | if (!dummy_frame) | |||
1283 | goto out; | |||
1284 | ||||
1285 | ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, | |||
1286 | peerinfo->mgmt, GLUSTERD_MGMT_STAGE_OP, | |||
1287 | NULL((void*)0), | |||
1288 | this, glusterd_stage_op_cbk, | |||
1289 | (xdrproc_t)xdr_gd1_mgmt_stage_op_req); | |||
1290 | ||||
1291 | out: | |||
1292 | if ((_gf_true == is_alloc) && req.buf.buf_val) | |||
1293 | GF_FREE (req.buf.buf_val)__gf_free (req.buf.buf_val); | |||
1294 | ||||
1295 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1295, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1296 | return ret; | |||
1297 | } | |||
1298 | ||||
1299 | int32_t | |||
1300 | glusterd_commit_op (call_frame_t *frame, xlator_t *this, | |||
1301 | void *data) | |||
1302 | { | |||
1303 | gd1_mgmt_commit_op_req req = {{0,},}; | |||
1304 | int ret = -1; | |||
1305 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); | |||
1306 | glusterd_conf_t *priv = NULL((void*)0); | |||
1307 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1308 | dict_t *dict = NULL((void*)0); | |||
1309 | gf_boolean_t is_alloc = _gf_true; | |||
1310 | ||||
1311 | if (!this) { | |||
1312 | goto out; | |||
1313 | } | |||
1314 | ||||
1315 | dict = data; | |||
1316 | priv = this->private; | |||
1317 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1317, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1318 | ||||
1319 | ret = dict_get_ptr (dict, "peerinfo", VOID (&peerinfo)((void **) ((void *) &peerinfo))); | |||
1320 | if (ret) | |||
1321 | goto out; | |||
1322 | ||||
1323 | //peerinfo should not be in payload | |||
1324 | dict_del (dict, "peerinfo"); | |||
1325 | ||||
1326 | glusterd_get_uuid (&req.uuid); | |||
1327 | req.op = glusterd_op_get_op (); | |||
1328 | ||||
1329 | ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, | |||
1330 | &req.buf.buf_len); | |||
1331 | if (ret) { | |||
1332 | gf_log (this->name, GF_LOG_ERROR, "Failed to serialize dict to "do { do { if (0) printf ("Failed to serialize dict to " "request buffer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1333, GF_LOG_ERROR, "Failed to serialize dict to " "request buffer"); } while (0) | |||
1333 | "request buffer")do { do { if (0) printf ("Failed to serialize dict to " "request buffer" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1333, GF_LOG_ERROR, "Failed to serialize dict to " "request buffer"); } while (0); | |||
1334 | goto out; | |||
1335 | } | |||
1336 | ||||
1337 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1338 | if (!dummy_frame) | |||
1339 | goto out; | |||
1340 | ||||
1341 | ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, | |||
1342 | peerinfo->mgmt, GLUSTERD_MGMT_COMMIT_OP, | |||
1343 | NULL((void*)0), | |||
1344 | this, glusterd_commit_op_cbk, | |||
1345 | (xdrproc_t)xdr_gd1_mgmt_commit_op_req); | |||
1346 | ||||
1347 | out: | |||
1348 | if ((_gf_true == is_alloc) && req.buf.buf_val) | |||
1349 | GF_FREE (req.buf.buf_val)__gf_free (req.buf.buf_val); | |||
1350 | ||||
1351 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1351, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1352 | return ret; | |||
1353 | } | |||
1354 | ||||
1355 | int32_t | |||
1356 | __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
1357 | int count, void *myframe) | |||
1358 | { | |||
1359 | gd1_mgmt_brick_op_rsp rsp = {0}; | |||
1360 | int ret = -1; | |||
1361 | int32_t op_ret = -1; | |||
1362 | glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; | |||
1363 | call_frame_t *frame = NULL((void*)0); | |||
1364 | glusterd_op_brick_rsp_ctx_t *ev_ctx = NULL((void*)0); | |||
1365 | dict_t *dict = NULL((void*)0); | |||
1366 | int index = 0; | |||
1367 | glusterd_req_ctx_t *req_ctx = NULL((void*)0); | |||
1368 | glusterd_pending_node_t *node = NULL((void*)0); | |||
1369 | xlator_t *this = NULL((void*)0); | |||
1370 | ||||
1371 | this = THIS(*__glusterfs_this_location()); | |||
1372 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1372, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); | |||
1373 | ||||
1374 | GF_ASSERT (req)do { if (!(req)) { do { do { if (0) printf ("Assertion failed: " "req"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1374, GF_LOG_ERROR, "Assertion failed: " "req" ); } while (0); } } while (0); | |||
1375 | frame = myframe; | |||
1376 | req_ctx = frame->local; | |||
1377 | ||||
1378 | if (-1 == req->rpc_status) { | |||
1379 | rsp.op_ret = -1; | |||
1380 | rsp.op_errno = EINVAL22; | |||
1381 | /* use standard allocation because to keep uniformity | |||
1382 | in freeing it */ | |||
1383 | rsp.op_errstr = strdup ("error"); | |||
1384 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
1385 | goto out; | |||
1386 | } | |||
1387 | ||||
1388 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); | |||
1389 | if (ret < 0) { | |||
1390 | gf_log (this->name, GF_LOG_ERROR, "Failed to decode brick op "do { do { if (0) printf ("Failed to decode brick op " "response received" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1391, GF_LOG_ERROR, "Failed to decode brick op " "response received"); } while (0) | |||
1391 | "response received")do { do { if (0) printf ("Failed to decode brick op " "response received" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1391, GF_LOG_ERROR, "Failed to decode brick op " "response received"); } while (0); | |||
1392 | rsp.op_ret = -1; | |||
1393 | rsp.op_errno = EINVAL22; | |||
1394 | rsp.op_errstr = strdup ("Unable to decode brick op response"); | |||
1395 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
1396 | goto out; | |||
1397 | } | |||
1398 | ||||
1399 | if (rsp.output.output_len) { | |||
1400 | /* Unserialize the dictionary */ | |||
1401 | dict = dict_new (); | |||
1402 | ||||
1403 | ret = dict_unserialize (rsp.output.output_val, | |||
1404 | rsp.output.output_len, | |||
1405 | &dict); | |||
1406 | if (ret < 0) { | |||
1407 | gf_log (this->name, GF_LOG_ERROR, "Failed to "do { do { if (0) printf ("Failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1408, GF_LOG_ERROR, "Failed to " "unserialize rsp-buffer to dictionary" ); } while (0) | |||
1408 | "unserialize rsp-buffer to dictionary")do { do { if (0) printf ("Failed to " "unserialize rsp-buffer to dictionary" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1408, GF_LOG_ERROR, "Failed to " "unserialize rsp-buffer to dictionary" ); } while (0); | |||
1409 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
1410 | goto out; | |||
1411 | } else { | |||
1412 | dict->extra_stdfree = rsp.output.output_val; | |||
1413 | } | |||
1414 | } | |||
1415 | ||||
1416 | op_ret = rsp.op_ret; | |||
1417 | ||||
1418 | /* Add index to rsp_dict for GD_OP_STATUS_VOLUME */ | |||
1419 | if (GD_OP_STATUS_VOLUME == req_ctx->op) { | |||
1420 | node = frame->cookie; | |||
1421 | index = node->index; | |||
1422 | ret = dict_set_int32 (dict, "index", index); | |||
1423 | if (ret) { | |||
1424 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error setting index on brick status rsp dict" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1425, GF_LOG_ERROR, "Error setting index on brick status rsp dict" ); } while (0) | |||
1425 | "Error setting index on brick status rsp dict")do { do { if (0) printf ("Error setting index on brick status rsp dict" ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1425, GF_LOG_ERROR, "Error setting index on brick status rsp dict" ); } while (0); | |||
1426 | rsp.op_ret = -1; | |||
1427 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
1428 | goto out; | |||
1429 | } | |||
1430 | } | |||
1431 | out: | |||
1432 | ev_ctx = GF_CALLOC (1, sizeof (*ev_ctx), gf_gld_mt_brick_rsp_ctx_t)__gf_calloc (1, sizeof (*ev_ctx), gf_gld_mt_brick_rsp_ctx_t); | |||
1433 | GF_ASSERT (ev_ctx)do { if (!(ev_ctx)) { do { do { if (0) printf ("Assertion failed: " "ev_ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1433, GF_LOG_ERROR, "Assertion failed: " "ev_ctx" ); } while (0); } } while (0); | |||
1434 | if (op_ret) { | |||
1435 | event_type = GD_OP_EVENT_RCVD_RJT; | |||
1436 | ev_ctx->op_ret = op_ret; | |||
1437 | ev_ctx->op_errstr = gf_strdup(rsp.op_errstr); | |||
1438 | } else { | |||
1439 | event_type = GD_OP_EVENT_RCVD_ACC; | |||
1440 | } | |||
1441 | ev_ctx->pending_node = frame->cookie; | |||
1442 | ev_ctx->rsp_dict = dict; | |||
1443 | ev_ctx->commit_ctx = frame->local; | |||
1444 | ret = glusterd_op_sm_inject_event (event_type, ev_ctx); | |||
1445 | if (!ret) { | |||
1446 | glusterd_friend_sm (); | |||
1447 | glusterd_op_sm (); | |||
1448 | } | |||
1449 | ||||
1450 | if (ret && dict) | |||
1451 | dict_unref (dict); | |||
1452 | free (rsp.op_errstr); //malloced by xdr | |||
1453 | GLUSTERD_STACK_DESTROY (frame)do { frame->local = ((void*)0); STACK_DESTROY (frame->root ); } while (0); | |||
1454 | return ret; | |||
1455 | } | |||
1456 | ||||
1457 | int32_t | |||
1458 | glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, | |||
1459 | int count, void *myframe) | |||
1460 | { | |||
1461 | return glusterd_big_locked_cbk (req, iov, count, myframe, | |||
1462 | __glusterd_brick_op_cbk); | |||
1463 | } | |||
1464 | ||||
1465 | int32_t | |||
1466 | glusterd_brick_op (call_frame_t *frame, xlator_t *this, | |||
1467 | void *data) | |||
1468 | { | |||
1469 | gd1_mgmt_brick_op_req *req = NULL((void*)0); | |||
1470 | int ret = 0; | |||
1471 | glusterd_conf_t *priv = NULL((void*)0); | |||
1472 | call_frame_t *dummy_frame = NULL((void*)0); | |||
1473 | char *op_errstr = NULL((void*)0); | |||
1474 | int pending_bricks = 0; | |||
1475 | glusterd_pending_node_t *pending_node; | |||
1476 | glusterd_req_ctx_t *req_ctx = NULL((void*)0); | |||
1477 | struct rpc_clnt *rpc = NULL((void*)0); | |||
1478 | dict_t *op_ctx = NULL((void*)0); | |||
1479 | ||||
1480 | if (!this) { | |||
1481 | ret = -1; | |||
1482 | goto out; | |||
1483 | } | |||
1484 | priv = this->private; | |||
1485 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1485, GF_LOG_ERROR, "Assertion failed: " "priv" ); } while (0); } } while (0); | |||
1486 | ||||
1487 | req_ctx = data; | |||
1488 | GF_ASSERT (req_ctx)do { if (!(req_ctx)) { do { do { if (0) printf ("Assertion failed: " "req_ctx"); } while (0); _gf_log_callingfn ("", "glusterd-rpc-ops.c" , __FUNCTION__, 1488, GF_LOG_ERROR, "Assertion failed: " "req_ctx" ); } while (0); } } while (0); | |||
1489 | INIT_LIST_HEAD (&opinfo.pending_bricks)do { (&opinfo.pending_bricks)->next = (&opinfo.pending_bricks )->prev = &opinfo.pending_bricks; } while (0); | |||
1490 | ret = glusterd_op_bricks_select (req_ctx->op, req_ctx->dict, &op_errstr, | |||
1491 | &opinfo.pending_bricks, NULL((void*)0)); | |||
1492 | ||||
1493 | if (ret) { | |||
1494 | gf_log (this->name, GF_LOG_ERROR, "Failed to select bricks "do { do { if (0) printf ("Failed to select bricks " "while performing brick op during 'Volume %s'" , gd_op_list[opinfo.op]); } while (0); _gf_log (this->name , "glusterd-rpc-ops.c", __FUNCTION__, 1496, GF_LOG_ERROR, "Failed to select bricks " "while performing brick op during 'Volume %s'", gd_op_list[opinfo .op]); } while (0) | |||
1495 | "while performing brick op during 'Volume %s'",do { do { if (0) printf ("Failed to select bricks " "while performing brick op during 'Volume %s'" , gd_op_list[opinfo.op]); } while (0); _gf_log (this->name , "glusterd-rpc-ops.c", __FUNCTION__, 1496, GF_LOG_ERROR, "Failed to select bricks " "while performing brick op during 'Volume %s'", gd_op_list[opinfo .op]); } while (0) | |||
1496 | gd_op_list[opinfo.op])do { do { if (0) printf ("Failed to select bricks " "while performing brick op during 'Volume %s'" , gd_op_list[opinfo.op]); } while (0); _gf_log (this->name , "glusterd-rpc-ops.c", __FUNCTION__, 1496, GF_LOG_ERROR, "Failed to select bricks " "while performing brick op during 'Volume %s'", gd_op_list[opinfo .op]); } while (0); | |||
1497 | opinfo.op_errstr = op_errstr; | |||
1498 | goto out; | |||
1499 | } | |||
1500 | ||||
1501 | list_for_each_entry (pending_node, &opinfo.pending_bricks, list)for (pending_node = ((typeof(*pending_node) *)((char *)((& opinfo.pending_bricks)->next)-(unsigned long)(&((typeof (*pending_node) *)0)->list))); &pending_node->list != (&opinfo.pending_bricks); pending_node = ((typeof(*pending_node ) *)((char *)(pending_node->list.next)-(unsigned long)(& ((typeof(*pending_node) *)0)->list)))) { | |||
1502 | dummy_frame = create_frame (this, this->ctx->pool); | |||
1503 | if (!dummy_frame) | |||
1504 | continue; | |||
1505 | ||||
1506 | if ((pending_node->type == GD_NODE_NFS) || | |||
1507 | ((pending_node->type == GD_NODE_SHD) && | |||
1508 | (req_ctx->op == GD_OP_STATUS_VOLUME))) | |||
1509 | ret = glusterd_node_op_build_payload | |||
1510 | (req_ctx->op, | |||
1511 | (gd1_mgmt_brick_op_req **)&req, | |||
1512 | req_ctx->dict); | |||
1513 | else { | |||
1514 | ret = glusterd_brick_op_build_payload | |||
1515 | (req_ctx->op, pending_node->node, | |||
1516 | (gd1_mgmt_brick_op_req **)&req, | |||
1517 | req_ctx->dict); | |||
1518 | ||||
1519 | if (ret) { | |||
1520 | gf_log (this->name, GF_LOG_ERROR, "Failed to "do { do { if (0) printf ("Failed to " "build brick op payload during " "'Volume %s'", gd_op_list[req_ctx->op]); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1522, GF_LOG_ERROR , "Failed to " "build brick op payload during " "'Volume %s'" , gd_op_list[req_ctx->op]); } while (0) | |||
1521 | "build brick op payload during "do { do { if (0) printf ("Failed to " "build brick op payload during " "'Volume %s'", gd_op_list[req_ctx->op]); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1522, GF_LOG_ERROR , "Failed to " "build brick op payload during " "'Volume %s'" , gd_op_list[req_ctx->op]); } while (0) | |||
1522 | "'Volume %s'", gd_op_list[req_ctx->op])do { do { if (0) printf ("Failed to " "build brick op payload during " "'Volume %s'", gd_op_list[req_ctx->op]); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1522, GF_LOG_ERROR , "Failed to " "build brick op payload during " "'Volume %s'" , gd_op_list[req_ctx->op]); } while (0); | |||
1523 | goto out; | |||
1524 | } | |||
1525 | } | |||
1526 | ||||
1527 | dummy_frame->local = data; | |||
1528 | dummy_frame->cookie = pending_node; | |||
1529 | ||||
1530 | rpc = glusterd_pending_node_get_rpc (pending_node); | |||
1531 | if (!rpc) { | |||
1532 | if (pending_node->type == GD_NODE_REBALANCE) { | |||
1533 | opinfo.brick_pending_count = 0; | |||
1534 | ret = 0; | |||
1535 | if (req) { | |||
1536 | GF_FREE (req->input.input_val)__gf_free (req->input.input_val); | |||
1537 | GF_FREE (req)__gf_free (req); | |||
1538 | req = NULL((void*)0); | |||
1539 | } | |||
1540 | GLUSTERD_STACK_DESTROY (dummy_frame)do { dummy_frame->local = ((void*)0); STACK_DESTROY (dummy_frame ->root); } while (0); | |||
1541 | ||||
1542 | op_ctx = glusterd_op_get_ctx (); | |||
1543 | if (!op_ctx) | |||
1544 | goto out; | |||
1545 | glusterd_defrag_volume_node_rsp (req_ctx->dict, | |||
1546 | NULL((void*)0), op_ctx); | |||
1547 | ||||
1548 | goto out; | |||
1549 | } | |||
1550 | ||||
1551 | ret = -1; | |||
1552 | gf_log (this->name, GF_LOG_ERROR, "Brick Op failed "do { do { if (0) printf ("Brick Op failed " "due to rpc failure." ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1553, GF_LOG_ERROR, "Brick Op failed " "due to rpc failure." ); } while (0) | |||
1553 | "due to rpc failure.")do { do { if (0) printf ("Brick Op failed " "due to rpc failure." ); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1553, GF_LOG_ERROR, "Brick Op failed " "due to rpc failure." ); } while (0); | |||
1554 | goto out; | |||
1555 | } | |||
1556 | ||||
1557 | ret = glusterd_submit_request (rpc, req, dummy_frame, | |||
1558 | priv->gfs_mgmt, | |||
1559 | req->op, NULL((void*)0), | |||
1560 | this, glusterd_brick_op_cbk, | |||
1561 | (xdrproc_t)xdr_gd1_mgmt_brick_op_req); | |||
1562 | if (req) { | |||
1563 | GF_FREE (req->input.input_val)__gf_free (req->input.input_val); | |||
1564 | GF_FREE (req)__gf_free (req); | |||
1565 | req = NULL((void*)0); | |||
1566 | } | |||
1567 | if (!ret) | |||
1568 | pending_bricks++; | |||
1569 | } | |||
1570 | ||||
1571 | gf_log (this->name, GF_LOG_DEBUG, "Sent brick op req for operation "do { do { if (0) printf ("Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1573, GF_LOG_DEBUG , "Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0) | |||
1572 | "'Volume %s' to %d bricks", gd_op_list[req_ctx->op],do { do { if (0) printf ("Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1573, GF_LOG_DEBUG , "Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0) | |||
1573 | pending_bricks)do { do { if (0) printf ("Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1573, GF_LOG_DEBUG , "Sent brick op req for operation " "'Volume %s' to %d bricks" , gd_op_list[req_ctx->op], pending_bricks); } while (0); | |||
1574 | opinfo.brick_pending_count = pending_bricks; | |||
1575 | ||||
1576 | out: | |||
1577 | if (ret) { | |||
1578 | glusterd_op_sm_inject_event (GD_OP_EVENT_RCVD_RJT, data); | |||
1579 | opinfo.op_ret = ret; | |||
1580 | } | |||
1581 | gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log (this->name, "glusterd-rpc-ops.c", __FUNCTION__, 1581, GF_LOG_DEBUG , "Returning %d", ret); } while (0); | |||
1582 | return ret; | |||
1583 | } | |||
1584 | ||||
1585 | struct rpc_clnt_procedure gd_brick_actors[GLUSTERD_BRICK_MAXVALUE] = { | |||
1586 | [GLUSTERD_BRICK_NULL] = {"NULL", NULL((void*)0) }, | |||
1587 | [GLUSTERD_BRICK_OP] = {"BRICK_OP", glusterd_brick_op}, | |||
1588 | }; | |||
1589 | ||||
1590 | struct rpc_clnt_procedure gd_peer_actors[GLUSTERD_FRIEND_MAXVALUE] = { | |||
1591 | [GLUSTERD_FRIEND_NULL] = {"NULL", NULL((void*)0) }, | |||
1592 | [GLUSTERD_PROBE_QUERY] = {"PROBE_QUERY", glusterd_rpc_probe}, | |||
1593 | [GLUSTERD_FRIEND_ADD] = {"FRIEND_ADD", glusterd_rpc_friend_add}, | |||
1594 | [GLUSTERD_FRIEND_REMOVE] = {"FRIEND_REMOVE", glusterd_rpc_friend_remove}, | |||
1595 | [GLUSTERD_FRIEND_UPDATE] = {"FRIEND_UPDATE", glusterd_rpc_friend_update}, | |||
1596 | }; | |||
1597 | ||||
1598 | struct rpc_clnt_procedure gd_mgmt_actors[GLUSTERD_MGMT_MAXVALUE] = { | |||
1599 | [GLUSTERD_MGMT_NULL] = {"NULL", NULL((void*)0) }, | |||
1600 | [GLUSTERD_MGMT_CLUSTER_LOCK] = {"CLUSTER_LOCK", glusterd_cluster_lock}, | |||
1601 | [GLUSTERD_MGMT_CLUSTER_UNLOCK] = {"CLUSTER_UNLOCK", glusterd_cluster_unlock}, | |||
1602 | [GLUSTERD_MGMT_STAGE_OP] = {"STAGE_OP", glusterd_stage_op}, | |||
1603 | [GLUSTERD_MGMT_COMMIT_OP] = {"COMMIT_OP", glusterd_commit_op}, | |||
1604 | }; | |||
1605 | ||||
1606 | struct rpc_clnt_program gd_mgmt_prog = { | |||
1607 | .progname = "glusterd mgmt", | |||
1608 | .prognum = GD_MGMT_PROGRAM1238433, | |||
1609 | .progver = GD_MGMT_VERSION2, | |||
1610 | .proctable = gd_mgmt_actors, | |||
1611 | .numproc = GLUSTERD_MGMT_MAXVALUE, | |||
1612 | }; | |||
1613 | ||||
1614 | struct rpc_clnt_program gd_brick_prog = { | |||
1615 | .progname = "brick operations", | |||
1616 | .prognum = GD_BRICK_PROGRAM4867634, | |||
1617 | .progver = GD_BRICK_VERSION2, | |||
1618 | .proctable = gd_brick_actors, | |||
1619 | .numproc = GLUSTERD_BRICK_MAXVALUE, | |||
1620 | }; | |||
1621 | ||||
1622 | struct rpc_clnt_program gd_peer_prog = { | |||
1623 | .progname = "Peer mgmt", | |||
1624 | .prognum = GD_FRIEND_PROGRAM1238437, | |||
1625 | .progver = GD_FRIEND_VERSION2, | |||
1626 | .proctable = gd_peer_actors, | |||
1627 | .numproc = GLUSTERD_FRIEND_MAXVALUE, | |||
1628 | }; | |||
1629 | ||||
1630 |