File: | xlators/mgmt/glusterd/src/glusterd-syncop.c |
Location: | line 771, column 17 |
Description: | Value stored to 'ret' is never read |
1 | /* |
2 | Copyright (c) 2012-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 | /* rpc related syncops */ |
11 | #include "rpc-clnt.h" |
12 | #include "protocol-common.h" |
13 | #include "xdr-generic.h" |
14 | #include "glusterd1-xdr.h" |
15 | #include "glusterd-syncop.h" |
16 | |
17 | #include "glusterd.h" |
18 | #include "glusterd-op-sm.h" |
19 | #include "glusterd-utils.h" |
20 | |
21 | static inline void |
22 | gd_synctask_barrier_wait (struct syncargs *args, int count) |
23 | { |
24 | glusterd_conf_t *conf = THIS(*__glusterfs_this_location())->private; |
25 | |
26 | synclock_unlock (&conf->big_lock); |
27 | synctask_barrier_wait (args, count)syncbarrier_wait (&args->barrier, count); |
28 | synclock_lock (&conf->big_lock); |
29 | |
30 | syncbarrier_destroy (&args->barrier); |
31 | } |
32 | |
33 | static void |
34 | gd_collate_errors (struct syncargs *args, int op_ret, int op_errno, |
35 | char *op_errstr) |
36 | { |
37 | if (args->op_ret) |
38 | return; |
39 | args->op_ret = op_ret; |
40 | args->op_errno = op_errno; |
41 | if (op_ret && op_errstr && strcmp (op_errstr, "")) |
42 | args->errstr = gf_strdup (op_errstr); |
43 | } |
44 | |
45 | static void |
46 | gd_syncargs_init (struct syncargs *args, dict_t *op_ctx) |
47 | { |
48 | args->dict = op_ctx; |
49 | pthread_mutex_init (&args->lock_dict, NULL((void*)0)); |
50 | } |
51 | |
52 | static void |
53 | gd_stage_op_req_free (gd1_mgmt_stage_op_req *req) |
54 | { |
55 | if (!req) |
56 | return; |
57 | |
58 | GF_FREE (req->buf.buf_val)__gf_free (req->buf.buf_val); |
59 | GF_FREE (req)__gf_free (req); |
60 | } |
61 | |
62 | static void |
63 | gd_commit_op_req_free (gd1_mgmt_commit_op_req *req) |
64 | { |
65 | if (!req) |
66 | return; |
67 | |
68 | GF_FREE (req->buf.buf_val)__gf_free (req->buf.buf_val); |
69 | GF_FREE (req)__gf_free (req); |
70 | } |
71 | |
72 | static void |
73 | gd_brick_op_req_free (gd1_mgmt_brick_op_req *req) |
74 | { |
75 | if (!req) |
76 | return; |
77 | |
78 | if (strcmp (req->name, "") != 0) |
79 | GF_FREE (req->name)__gf_free (req->name); |
80 | GF_FREE (req->input.input_val)__gf_free (req->input.input_val); |
81 | GF_FREE (req)__gf_free (req); |
82 | } |
83 | |
84 | int |
85 | gd_syncop_submit_request (struct rpc_clnt *rpc, void *req, |
86 | void *cookie, rpc_clnt_prog_t *prog, |
87 | int procnum, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) |
88 | { |
89 | int ret = -1; |
90 | struct iobuf *iobuf = NULL((void*)0); |
91 | struct iobref *iobref = NULL((void*)0); |
92 | int count = 0; |
93 | struct iovec iov = {0, }; |
94 | ssize_t req_size = 0; |
95 | call_frame_t *frame = NULL((void*)0); |
96 | |
97 | GF_ASSERT (rpc)do { if (!(rpc)) { do { do { if (0) printf ("Assertion failed: " "rpc"); } while (0); _gf_log_callingfn ("", "glusterd-syncop.c" , __FUNCTION__, 97, GF_LOG_ERROR, "Assertion failed: " "rpc") ; } while (0); } } while (0); |
98 | if (!req) |
99 | goto out; |
100 | |
101 | req_size = xdr_sizeof (xdrproc, req); |
102 | iobuf = iobuf_get2 (rpc->ctx->iobuf_pool, req_size); |
103 | if (!iobuf) |
104 | goto out; |
105 | |
106 | iobref = iobref_new (); |
107 | if (!iobref) |
108 | goto out; |
109 | |
110 | frame = create_frame (THIS(*__glusterfs_this_location()), THIS(*__glusterfs_this_location())->ctx->pool); |
111 | if (!frame) |
112 | goto out; |
113 | |
114 | iobref_add (iobref, iobuf); |
115 | |
116 | iov.iov_base = iobuf->ptr; |
117 | iov.iov_len = iobuf_pagesize (iobuf)(iobuf->iobuf_arena->page_size); |
118 | |
119 | /* Create the xdr payload */ |
120 | ret = xdr_serialize_generic (iov, req, xdrproc); |
121 | if (ret == -1) |
122 | goto out; |
123 | |
124 | iov.iov_len = ret; |
125 | count = 1; |
126 | |
127 | frame->local = cookie; |
128 | |
129 | /* Send the msg */ |
130 | ret = rpc_clnt_submit (rpc, prog, procnum, cbkfn, |
131 | &iov, count, NULL((void*)0), 0, iobref, |
132 | frame, NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0)); |
133 | |
134 | /* TODO: do we need to start ping also? */ |
135 | |
136 | out: |
137 | iobref_unref (iobref); |
138 | iobuf_unref (iobuf); |
139 | |
140 | return ret; |
141 | } |
142 | |
143 | /* Defined in glusterd-rpc-ops.c */ |
144 | extern struct rpc_clnt_program gd_mgmt_prog; |
145 | extern struct rpc_clnt_program gd_brick_prog; |
146 | |
147 | static int |
148 | glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp) |
149 | { |
150 | int ret = 0; |
151 | |
152 | switch (op) { |
153 | case GD_OP_REPLACE_BRICK: |
154 | ret = glusterd_rb_use_rsp_dict (aggr, rsp); |
155 | if (ret) |
156 | goto out; |
157 | break; |
158 | |
159 | case GD_OP_SYNC_VOLUME: |
160 | ret = glusterd_sync_use_rsp_dict (aggr, rsp); |
161 | if (ret) |
162 | goto out; |
163 | break; |
164 | |
165 | case GD_OP_PROFILE_VOLUME: |
166 | ret = glusterd_profile_volume_use_rsp_dict (aggr, rsp); |
167 | if (ret) |
168 | goto out; |
169 | break; |
170 | |
171 | case GD_OP_GSYNC_SET: |
172 | ret = glusterd_gsync_use_rsp_dict (aggr, rsp, NULL((void*)0)); |
173 | if (ret) |
174 | goto out; |
175 | break; |
176 | |
177 | case GD_OP_STATUS_VOLUME: |
178 | ret = glusterd_volume_status_copy_to_op_ctx_dict (aggr, rsp); |
179 | if (ret) |
180 | goto out; |
181 | break; |
182 | |
183 | case GD_OP_REBALANCE: |
184 | case GD_OP_DEFRAG_BRICK_VOLUME: |
185 | ret = glusterd_volume_rebalance_use_rsp_dict (aggr, rsp); |
186 | if (ret) |
187 | goto out; |
188 | break; |
189 | |
190 | case GD_OP_HEAL_VOLUME: |
191 | ret = glusterd_volume_heal_use_rsp_dict (aggr, rsp); |
192 | if (ret) |
193 | goto out; |
194 | |
195 | break; |
196 | |
197 | case GD_OP_QUOTA: |
198 | case GD_OP_CLEARLOCKS_VOLUME: |
199 | ret = glusterd_use_rsp_dict (aggr, rsp); |
200 | if (ret) |
201 | goto out; |
202 | |
203 | break; |
204 | |
205 | default: |
206 | break; |
207 | } |
208 | out: |
209 | return ret; |
210 | } |
211 | |
212 | int32_t |
213 | _gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov, |
214 | int count, void *myframe) |
215 | { |
216 | int ret = -1; |
217 | struct syncargs *args = NULL((void*)0); |
218 | gd1_mgmt_cluster_lock_rsp rsp = {{0},}; |
219 | call_frame_t *frame = NULL((void*)0); |
220 | |
221 | frame = myframe; |
222 | args = frame->local; |
223 | frame->local = NULL((void*)0); |
224 | |
225 | if (-1 == req->rpc_status) { |
226 | args->op_errno = ENOTCONN107; |
227 | goto out; |
228 | } |
229 | |
230 | ret = xdr_to_generic (*iov, &rsp, |
231 | (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); |
232 | if (ret < 0) |
233 | goto out; |
234 | |
235 | gd_collate_errors (args, rsp.op_ret, rsp.op_errno, NULL((void*)0)); |
236 | uuid_copy (args->uuid, rsp.uuid); |
237 | |
238 | out: |
239 | STACK_DESTROY (frame->root); |
240 | synctask_barrier_wake(args)syncbarrier_wake (&args->barrier); |
241 | return 0; |
242 | } |
243 | |
244 | int32_t |
245 | gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov, |
246 | int count, void *myframe) |
247 | { |
248 | return glusterd_big_locked_cbk (req, iov, count, myframe, |
249 | _gd_syncop_mgmt_lock_cbk); |
250 | } |
251 | |
252 | int |
253 | gd_syncop_mgmt_lock (struct rpc_clnt *rpc, struct syncargs *args, |
254 | uuid_t my_uuid, uuid_t recv_uuid) |
255 | { |
256 | int ret = -1; |
257 | gd1_mgmt_cluster_lock_req req = {{0},}; |
258 | |
259 | uuid_copy (req.uuid, my_uuid); |
260 | ret = gd_syncop_submit_request (rpc, &req, args, &gd_mgmt_prog, |
261 | GLUSTERD_MGMT_CLUSTER_LOCK, |
262 | gd_syncop_mgmt_lock_cbk, |
263 | (xdrproc_t) xdr_gd1_mgmt_cluster_lock_req); |
264 | return ret; |
265 | } |
266 | |
267 | int32_t |
268 | _gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov, |
269 | int count, void *myframe) |
270 | { |
271 | int ret = -1; |
272 | struct syncargs *args = NULL((void*)0); |
273 | gd1_mgmt_cluster_unlock_rsp rsp = {{0},}; |
274 | call_frame_t *frame = NULL((void*)0); |
275 | |
276 | frame = myframe; |
277 | args = frame->local; |
278 | frame->local = NULL((void*)0); |
279 | |
280 | if (-1 == req->rpc_status) { |
281 | args->op_errno = ENOTCONN107; |
282 | goto out; |
283 | } |
284 | |
285 | ret = xdr_to_generic (*iov, &rsp, |
286 | (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp); |
287 | if (ret < 0) |
288 | goto out; |
289 | |
290 | gd_collate_errors (args, rsp.op_ret, rsp.op_errno, NULL((void*)0)); |
291 | uuid_copy (args->uuid, rsp.uuid); |
292 | |
293 | out: |
294 | STACK_DESTROY (frame->root); |
295 | synctask_barrier_wake(args)syncbarrier_wake (&args->barrier); |
296 | return 0; |
297 | } |
298 | |
299 | int32_t |
300 | gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov, |
301 | int count, void *myframe) |
302 | { |
303 | return glusterd_big_locked_cbk (req, iov, count, myframe, |
304 | _gd_syncop_mgmt_unlock_cbk); |
305 | } |
306 | |
307 | |
308 | int |
309 | gd_syncop_mgmt_unlock (struct rpc_clnt *rpc, struct syncargs *args, |
310 | uuid_t my_uuid, uuid_t recv_uuid) |
311 | { |
312 | int ret = -1; |
313 | gd1_mgmt_cluster_unlock_req req = {{0},}; |
314 | |
315 | uuid_copy (req.uuid, my_uuid); |
316 | ret = gd_syncop_submit_request (rpc, &req, args, &gd_mgmt_prog, |
317 | GLUSTERD_MGMT_CLUSTER_UNLOCK, |
318 | gd_syncop_mgmt_unlock_cbk, |
319 | (xdrproc_t) xdr_gd1_mgmt_cluster_lock_req); |
320 | return ret; |
321 | } |
322 | |
323 | int32_t |
324 | _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov, |
325 | int count, void *myframe) |
326 | { |
327 | int ret = -1; |
328 | gd1_mgmt_stage_op_rsp rsp = {{0},}; |
329 | struct syncargs *args = NULL((void*)0); |
330 | xlator_t *this = NULL((void*)0); |
331 | dict_t *rsp_dict = NULL((void*)0); |
332 | call_frame_t *frame = NULL((void*)0); |
333 | |
334 | this = THIS(*__glusterfs_this_location()); |
335 | frame = myframe; |
336 | args = frame->local; |
337 | frame->local = NULL((void*)0); |
338 | |
339 | if (-1 == req->rpc_status) { |
340 | args->op_ret = -1; |
341 | args->op_errno = ENOTCONN107; |
342 | goto out; |
343 | } |
344 | |
345 | ret = xdr_to_generic (*iov, &rsp, |
346 | (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); |
347 | if (ret < 0) |
348 | goto out; |
349 | |
350 | if (rsp.dict.dict_len) { |
351 | /* Unserialize the dictionary */ |
352 | rsp_dict = dict_new (); |
353 | |
354 | ret = dict_unserialize (rsp.dict.dict_val, |
355 | rsp.dict.dict_len, |
356 | &rsp_dict); |
357 | if (ret < 0) { |
358 | GF_FREE (rsp.dict.dict_val)__gf_free (rsp.dict.dict_val); |
359 | goto out; |
360 | } else { |
361 | rsp_dict->extra_stdfree = rsp.dict.dict_val; |
362 | } |
363 | } |
364 | |
365 | gd_collate_errors (args, rsp.op_ret, rsp.op_errno, rsp.op_errstr); |
366 | uuid_copy (args->uuid, rsp.uuid); |
367 | if (rsp.op == GD_OP_REPLACE_BRICK) { |
368 | pthread_mutex_lock (&args->lock_dict); |
369 | { |
370 | ret = glusterd_syncop_aggr_rsp_dict (rsp.op, args->dict, |
371 | rsp_dict); |
372 | if (ret) |
373 | gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 375, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0) |
374 | "Failed to aggregate response from "do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 375, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0) |
375 | " node/brick")do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 375, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0); |
376 | } |
377 | pthread_mutex_unlock (&args->lock_dict); |
378 | } |
379 | |
380 | out: |
381 | if (rsp_dict) |
382 | dict_unref (rsp_dict); |
383 | |
384 | STACK_DESTROY (frame->root); |
385 | synctask_barrier_wake(args)syncbarrier_wake (&args->barrier); |
386 | return 0; |
387 | } |
388 | |
389 | int32_t |
390 | gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov, |
391 | int count, void *myframe) |
392 | { |
393 | return glusterd_big_locked_cbk (req, iov, count, myframe, |
394 | _gd_syncop_stage_op_cbk); |
395 | } |
396 | |
397 | |
398 | int |
399 | gd_syncop_mgmt_stage_op (struct rpc_clnt *rpc, struct syncargs *args, |
400 | uuid_t my_uuid, uuid_t recv_uuid, int op, |
401 | dict_t *dict_out, dict_t *op_ctx) |
402 | { |
403 | gd1_mgmt_stage_op_req *req = NULL((void*)0); |
404 | int ret = -1; |
405 | |
406 | req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_stage_req_t)__gf_calloc (1, sizeof (*req), gf_gld_mt_mop_stage_req_t); |
407 | if (!req) |
408 | goto out; |
409 | |
410 | uuid_copy (req->uuid, my_uuid); |
411 | req->op = op; |
412 | |
413 | ret = dict_allocate_and_serialize (dict_out, |
414 | &req->buf.buf_val, &req->buf.buf_len); |
415 | if (ret) |
416 | goto out; |
417 | |
418 | ret = gd_syncop_submit_request (rpc, req, args, &gd_mgmt_prog, |
419 | GLUSTERD_MGMT_STAGE_OP, |
420 | gd_syncop_stage_op_cbk, |
421 | (xdrproc_t) xdr_gd1_mgmt_stage_op_req); |
422 | out: |
423 | gd_stage_op_req_free (req); |
424 | return ret; |
425 | |
426 | } |
427 | |
428 | int32_t |
429 | _gd_syncop_brick_op_cbk (struct rpc_req *req, struct iovec *iov, |
430 | int count, void *myframe) |
431 | { |
432 | struct syncargs *args = NULL((void*)0); |
433 | gd1_mgmt_brick_op_rsp rsp = {0,}; |
434 | int ret = -1; |
435 | call_frame_t *frame = NULL((void*)0); |
436 | |
437 | frame = myframe; |
438 | args = frame->local; |
439 | frame->local = NULL((void*)0); |
440 | |
441 | /* initialize */ |
442 | args->op_ret = -1; |
443 | args->op_errno = EINVAL22; |
444 | |
445 | if (-1 == req->rpc_status) { |
446 | args->op_errno = ENOTCONN107; |
447 | goto out; |
448 | } |
449 | |
450 | ret = xdr_to_generic (*iov, &rsp, |
451 | (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); |
452 | if (ret < 0) |
453 | goto out; |
454 | |
455 | if (rsp.output.output_len) { |
456 | args->dict = dict_new (); |
457 | if (!args->dict) { |
458 | ret = -1; |
459 | args->op_errno = ENOMEM12; |
460 | goto out; |
461 | } |
462 | |
463 | ret = dict_unserialize (rsp.output.output_val, |
464 | rsp.output.output_len, |
465 | &args->dict); |
466 | if (ret < 0) |
467 | goto out; |
468 | } |
469 | |
470 | args->op_ret = rsp.op_ret; |
471 | args->op_errno = rsp.op_errno; |
472 | args->errstr = gf_strdup (rsp.op_errstr); |
473 | |
474 | out: |
475 | if (strcmp (rsp.op_errstr, "") != 0) |
476 | free (rsp.op_errstr); |
477 | free (rsp.output.output_val); |
478 | |
479 | STACK_DESTROY (frame->root); |
480 | __wake (args)do { if (args->task) { synctask_wake (args->task); } else { pthread_mutex_lock (&args->mutex); { args->done = 1; pthread_cond_signal (&args->cond); } pthread_mutex_unlock (&args->mutex); } } while (0); |
481 | |
482 | return 0; |
483 | } |
484 | |
485 | int32_t |
486 | gd_syncop_brick_op_cbk (struct rpc_req *req, struct iovec *iov, |
487 | int count, void *myframe) |
488 | { |
489 | return glusterd_big_locked_cbk (req, iov, count, myframe, |
490 | _gd_syncop_brick_op_cbk); |
491 | } |
492 | |
493 | int |
494 | gd_syncop_mgmt_brick_op (struct rpc_clnt *rpc, glusterd_pending_node_t *pnode, |
495 | int op, dict_t *dict_out, dict_t *op_ctx, |
496 | char **errstr) |
497 | { |
498 | struct syncargs args = {0, }; |
499 | gd1_mgmt_brick_op_req *req = NULL((void*)0); |
500 | int ret = 0; |
501 | xlator_t *this = NULL((void*)0); |
502 | |
503 | this = THIS(*__glusterfs_this_location()); |
504 | args.op_ret = -1; |
505 | args.op_errno = ENOTCONN107; |
506 | |
507 | if ((pnode->type == GD_NODE_NFS) || |
508 | ((pnode->type == GD_NODE_SHD) && |
509 | (op == GD_OP_STATUS_VOLUME))) { |
510 | ret = glusterd_node_op_build_payload |
511 | (op, &req, dict_out); |
512 | |
513 | } else { |
514 | ret = glusterd_brick_op_build_payload |
515 | (op, pnode->node, &req, dict_out); |
516 | |
517 | } |
518 | |
519 | if (ret) |
520 | goto out; |
521 | |
522 | GD_SYNCOP (rpc, (&args), gd_syncop_brick_op_cbk,do { int ret = 0; struct synctask *task = ((void*)0); glusterd_conf_t *conf= (*__glusterfs_this_location())->private; task = synctask_get (); (&args)->task = task; synclock_unlock (&conf-> big_lock); ret = gd_syncop_submit_request (rpc, req, (&args ), &gd_brick_prog, req->op, gd_syncop_brick_op_cbk, (xdrproc_t )xdr_gd1_mgmt_brick_op_req); if (!ret) synctask_yield ((& args)->task); synclock_lock (&conf->big_lock); } while (0) |
523 | req, &gd_brick_prog, req->op,do { int ret = 0; struct synctask *task = ((void*)0); glusterd_conf_t *conf= (*__glusterfs_this_location())->private; task = synctask_get (); (&args)->task = task; synclock_unlock (&conf-> big_lock); ret = gd_syncop_submit_request (rpc, req, (&args ), &gd_brick_prog, req->op, gd_syncop_brick_op_cbk, (xdrproc_t )xdr_gd1_mgmt_brick_op_req); if (!ret) synctask_yield ((& args)->task); synclock_lock (&conf->big_lock); } while (0) |
524 | xdr_gd1_mgmt_brick_op_req)do { int ret = 0; struct synctask *task = ((void*)0); glusterd_conf_t *conf= (*__glusterfs_this_location())->private; task = synctask_get (); (&args)->task = task; synclock_unlock (&conf-> big_lock); ret = gd_syncop_submit_request (rpc, req, (&args ), &gd_brick_prog, req->op, gd_syncop_brick_op_cbk, (xdrproc_t )xdr_gd1_mgmt_brick_op_req); if (!ret) synctask_yield ((& args)->task); synclock_lock (&conf->big_lock); } while (0); |
525 | |
526 | if (args.errstr && errstr) |
527 | *errstr = args.errstr; |
528 | else |
529 | GF_FREE (args.errstr)__gf_free (args.errstr); |
530 | |
531 | if (GD_OP_STATUS_VOLUME == op) { |
532 | ret = dict_set_int32 (args.dict, "index", pnode->index); |
533 | if (ret) { |
534 | 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-syncop.c" , __FUNCTION__, 536, GF_LOG_ERROR, "Error setting index on brick status" " rsp dict"); } while (0) |
535 | "Error setting index on brick status"do { do { if (0) printf ("Error setting index on brick status" " rsp dict"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 536, GF_LOG_ERROR, "Error setting index on brick status" " rsp dict"); } while (0) |
536 | " rsp dict")do { do { if (0) printf ("Error setting index on brick status" " rsp dict"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 536, GF_LOG_ERROR, "Error setting index on brick status" " rsp dict"); } while (0); |
537 | args.op_ret = -1; |
538 | goto out; |
539 | } |
540 | } |
541 | if (args.op_ret == 0) |
542 | glusterd_handle_node_rsp (dict_out, pnode->node, op, |
543 | args.dict, op_ctx, errstr, |
544 | pnode->type); |
545 | |
546 | out: |
547 | errno(*__errno_location ()) = args.op_errno; |
548 | if (args.dict) |
549 | dict_unref (args.dict); |
550 | gd_brick_op_req_free (req); |
551 | return args.op_ret; |
552 | |
553 | } |
554 | |
555 | int32_t |
556 | _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov, |
557 | int count, void *myframe) |
558 | { |
559 | int ret = -1; |
560 | gd1_mgmt_commit_op_rsp rsp = {{0},}; |
561 | struct syncargs *args = NULL((void*)0); |
562 | xlator_t *this = NULL((void*)0); |
563 | dict_t *rsp_dict = NULL((void*)0); |
564 | call_frame_t *frame = NULL((void*)0); |
565 | |
566 | this = THIS(*__glusterfs_this_location()); |
567 | frame = myframe; |
568 | args = frame->local; |
569 | frame->local = NULL((void*)0); |
570 | |
571 | if (-1 == req->rpc_status) { |
572 | args->op_errno = ENOTCONN107; |
573 | goto out; |
574 | } |
575 | |
576 | ret = xdr_to_generic (*iov, &rsp, |
577 | (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); |
578 | if (ret < 0) { |
579 | goto out; |
580 | } |
581 | |
582 | if (rsp.dict.dict_len) { |
583 | /* Unserialize the dictionary */ |
584 | rsp_dict = dict_new (); |
585 | |
586 | ret = dict_unserialize (rsp.dict.dict_val, |
587 | rsp.dict.dict_len, |
588 | &rsp_dict); |
589 | if (ret < 0) { |
590 | GF_FREE (rsp.dict.dict_val)__gf_free (rsp.dict.dict_val); |
591 | goto out; |
592 | } else { |
593 | rsp_dict->extra_stdfree = rsp.dict.dict_val; |
594 | } |
595 | } |
596 | |
597 | gd_collate_errors (args, rsp.op_ret, rsp.op_errno, rsp.op_errstr); |
598 | uuid_copy (args->uuid, rsp.uuid); |
599 | pthread_mutex_lock (&args->lock_dict); |
600 | { |
601 | ret = glusterd_syncop_aggr_rsp_dict (rsp.op, args->dict, |
602 | rsp_dict); |
603 | if (ret) |
604 | gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 606, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0) |
605 | "Failed to aggregate response from "do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 606, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0) |
606 | " node/brick")do { do { if (0) printf ("%s", "Failed to aggregate response from " " node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 606, GF_LOG_ERROR, "%s", "Failed to aggregate response from " " node/brick"); } while (0); |
607 | } |
608 | pthread_mutex_unlock (&args->lock_dict); |
609 | out: |
610 | if (rsp_dict) |
611 | dict_unref (rsp_dict); |
612 | |
613 | STACK_DESTROY (frame->root); |
614 | synctask_barrier_wake(args)syncbarrier_wake (&args->barrier); |
615 | |
616 | return 0; |
617 | } |
618 | |
619 | int32_t |
620 | gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov, |
621 | int count, void *myframe) |
622 | { |
623 | return glusterd_big_locked_cbk (req, iov, count, myframe, |
624 | _gd_syncop_commit_op_cbk); |
625 | } |
626 | |
627 | |
628 | int |
629 | gd_syncop_mgmt_commit_op (struct rpc_clnt *rpc, struct syncargs *args, |
630 | uuid_t my_uuid, uuid_t recv_uuid, |
631 | int op, dict_t *dict_out, dict_t *op_ctx) |
632 | { |
633 | gd1_mgmt_commit_op_req *req = NULL((void*)0); |
634 | int ret = -1; |
635 | |
636 | req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_commit_req_t)__gf_calloc (1, sizeof (*req), gf_gld_mt_mop_commit_req_t); |
637 | if (!req) |
638 | goto out; |
639 | |
640 | uuid_copy (req->uuid, my_uuid); |
641 | req->op = op; |
642 | |
643 | ret = dict_allocate_and_serialize (dict_out, |
644 | &req->buf.buf_val, &req->buf.buf_len); |
645 | if (ret) |
646 | goto out; |
647 | |
648 | ret = gd_syncop_submit_request (rpc, req, args, &gd_mgmt_prog, |
649 | GLUSTERD_MGMT_COMMIT_OP , |
650 | gd_syncop_commit_op_cbk, |
651 | (xdrproc_t) xdr_gd1_mgmt_commit_op_req); |
652 | out: |
653 | gd_commit_op_req_free (req); |
654 | return ret; |
655 | } |
656 | |
657 | |
658 | int |
659 | gd_build_peers_list (struct list_head *peers, struct list_head *xact_peers, |
660 | glusterd_op_t op) |
661 | { |
662 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); |
663 | int npeers = 0; |
664 | |
665 | list_for_each_entry (peerinfo, peers, uuid_list)for (peerinfo = ((typeof(*peerinfo) *)((char *)((peers)->next )-(unsigned long)(&((typeof(*peerinfo) *)0)->uuid_list ))); &peerinfo->uuid_list != (peers); peerinfo = ((typeof (*peerinfo) *)((char *)(peerinfo->uuid_list.next)-(unsigned long)(&((typeof(*peerinfo) *)0)->uuid_list)))) { |
666 | if (!peerinfo->connected) |
667 | continue; |
668 | if (op != GD_OP_SYNC_VOLUME && |
669 | peerinfo->state.state != GD_FRIEND_STATE_BEFRIENDED) |
670 | continue; |
671 | |
672 | list_add_tail (&peerinfo->op_peers_list, xact_peers); |
673 | npeers++; |
674 | } |
675 | return npeers; |
676 | } |
677 | |
678 | int |
679 | gd_lock_op_phase (struct list_head *peers, glusterd_op_t op, dict_t *op_ctx, |
680 | char **op_errstr, int npeers) |
681 | { |
682 | int ret = -1; |
683 | int peer_cnt = 0; |
684 | uuid_t peer_uuid = {0}; |
685 | xlator_t *this = NULL((void*)0); |
686 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); |
687 | struct syncargs args = {0}; |
688 | |
689 | if (!npeers) { |
690 | ret = 0; |
691 | goto out; |
692 | } |
693 | |
694 | this = THIS(*__glusterfs_this_location()); |
695 | synctask_barrier_init((&args))syncbarrier_init (&(&args)->barrier); |
696 | peer_cnt = 0; |
697 | list_for_each_entry (peerinfo, peers, op_peers_list)for (peerinfo = ((typeof(*peerinfo) *)((char *)((peers)->next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list ))); &peerinfo->op_peers_list != (peers); peerinfo = ( (typeof(*peerinfo) *)((char *)(peerinfo->op_peers_list.next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list )))) { |
698 | gd_syncop_mgmt_lock (peerinfo->rpc, &args, MY_UUID(__glusterd_uuid()), peer_uuid); |
699 | peer_cnt++; |
700 | } |
701 | gd_synctask_barrier_wait((&args), peer_cnt); |
702 | ret = args.op_ret; |
703 | if (ret) { |
704 | gf_asprintf (op_errstr, "Another transaction could be " |
705 | "in progress. Please try again after " |
706 | "sometime."); |
707 | gf_log (this->name, GF_LOG_ERROR, "Failed to acquire lock")do { do { if (0) printf ("Failed to acquire lock"); } while ( 0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 707, GF_LOG_ERROR, "Failed to acquire lock"); } while (0); |
708 | goto out; |
709 | } |
710 | |
711 | ret = 0; |
712 | out: |
713 | return ret; |
714 | } |
715 | |
716 | int |
717 | gd_stage_op_phase (struct list_head *peers, glusterd_op_t op, dict_t *op_ctx, |
718 | dict_t *req_dict, char **op_errstr, int npeers) |
719 | { |
720 | int ret = -1; |
721 | int peer_cnt = 0; |
722 | dict_t *rsp_dict = NULL((void*)0); |
723 | char *hostname = NULL((void*)0); |
724 | xlator_t *this = NULL((void*)0); |
725 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); |
726 | uuid_t tmp_uuid = {0}; |
727 | char *errstr = NULL((void*)0); |
728 | struct syncargs args = {0}; |
729 | |
730 | this = THIS(*__glusterfs_this_location()); |
731 | rsp_dict = dict_new (); |
732 | if (!rsp_dict) |
733 | goto out; |
734 | |
735 | ret = glusterd_op_stage_validate (op, req_dict, op_errstr, rsp_dict); |
736 | if (ret) { |
737 | hostname = "localhost"; |
738 | goto stage_done; |
739 | } |
740 | |
741 | if ((op == GD_OP_REPLACE_BRICK)) { |
742 | ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx, rsp_dict); |
743 | if (ret) { |
744 | gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", "Failed to aggregate response from node/brick" ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 745, GF_LOG_ERROR, "%s", "Failed to aggregate response from node/brick" ); } while (0) |
745 | "Failed to aggregate response from node/brick")do { do { if (0) printf ("%s", "Failed to aggregate response from node/brick" ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 745, GF_LOG_ERROR, "%s", "Failed to aggregate response from node/brick" ); } while (0); |
746 | goto out; |
747 | } |
748 | } |
749 | dict_unref (rsp_dict); |
750 | rsp_dict = NULL((void*)0); |
751 | |
752 | stage_done: |
753 | if (ret) { |
754 | gf_log (this->name, GF_LOG_ERROR, LOGSTR_STAGE_FAIL,do { do { if (0) printf ("Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 756, GF_LOG_ERROR, "Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0) |
755 | gd_op_list[op], hostname, (*op_errstr) ? ":" : " ",do { do { if (0) printf ("Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 756, GF_LOG_ERROR, "Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0) |
756 | (*op_errstr) ? *op_errstr : " ")do { do { if (0) printf ("Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 756, GF_LOG_ERROR, "Staging of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); |
757 | if (*op_errstr == NULL((void*)0)) |
758 | gf_asprintf (op_errstr, OPERRSTR_STAGE_FAIL"Staging failed on %s. Please check the log file " "for more details.", hostname); |
759 | goto out; |
760 | } |
761 | |
762 | if (!npeers) { |
763 | ret = 0; |
764 | goto out; |
765 | } |
766 | |
767 | gd_syncargs_init (&args, op_ctx); |
768 | synctask_barrier_init((&args))syncbarrier_init (&(&args)->barrier); |
769 | peer_cnt = 0; |
770 | list_for_each_entry (peerinfo, peers, op_peers_list)for (peerinfo = ((typeof(*peerinfo) *)((char *)((peers)->next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list ))); &peerinfo->op_peers_list != (peers); peerinfo = ( (typeof(*peerinfo) *)((char *)(peerinfo->op_peers_list.next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list )))) { |
771 | ret = gd_syncop_mgmt_stage_op (peerinfo->rpc, &args, |
Value stored to 'ret' is never read | |
772 | MY_UUID(__glusterd_uuid()), tmp_uuid, |
773 | op, req_dict, op_ctx); |
774 | peer_cnt++; |
775 | } |
776 | gd_synctask_barrier_wait((&args), peer_cnt); |
777 | ret = args.op_ret; |
778 | if (dict_get_str (op_ctx, "errstr", &errstr) == 0) |
779 | *op_errstr = gf_strdup (errstr); |
780 | |
781 | out: |
782 | if (rsp_dict) |
783 | dict_unref (rsp_dict); |
784 | return ret; |
785 | } |
786 | |
787 | int |
788 | gd_commit_op_phase (struct list_head *peers, glusterd_op_t op, dict_t *op_ctx, |
789 | dict_t *req_dict, char **op_errstr, int npeers) |
790 | { |
791 | dict_t *rsp_dict = NULL((void*)0); |
792 | int peer_cnt = -1; |
793 | int ret = -1; |
794 | char *hostname = NULL((void*)0); |
795 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); |
796 | xlator_t *this = NULL((void*)0); |
797 | uuid_t tmp_uuid = {0}; |
798 | char *errstr = NULL((void*)0); |
799 | struct syncargs args = {0}; |
800 | |
801 | this = THIS(*__glusterfs_this_location()); |
802 | rsp_dict = dict_new (); |
803 | if (!rsp_dict) { |
804 | ret = -1; |
805 | goto out; |
806 | } |
807 | |
808 | ret = glusterd_op_commit_perform (op, req_dict, op_errstr, rsp_dict); |
809 | if (ret) { |
810 | hostname = "localhost"; |
811 | goto commit_done; |
812 | } |
813 | if (op != GD_OP_SYNC_VOLUME) { |
814 | ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx, rsp_dict); |
815 | if (ret) { |
816 | gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", "Failed to aggregate response " "from node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 818, GF_LOG_ERROR, "%s", "Failed to aggregate response " "from node/brick"); } while (0) |
817 | "Failed to aggregate response "do { do { if (0) printf ("%s", "Failed to aggregate response " "from node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 818, GF_LOG_ERROR, "%s", "Failed to aggregate response " "from node/brick"); } while (0) |
818 | "from node/brick")do { do { if (0) printf ("%s", "Failed to aggregate response " "from node/brick"); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 818, GF_LOG_ERROR, "%s", "Failed to aggregate response " "from node/brick"); } while (0); |
819 | goto out; |
820 | } |
821 | } |
822 | dict_unref (rsp_dict); |
823 | rsp_dict = NULL((void*)0); |
824 | |
825 | commit_done: |
826 | if (ret) { |
827 | gf_log (this->name, GF_LOG_ERROR, LOGSTR_COMMIT_FAIL,do { do { if (0) printf ("Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 829, GF_LOG_ERROR, "Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0) |
828 | gd_op_list[op], hostname, (*op_errstr) ? ":" : " ",do { do { if (0) printf ("Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 829, GF_LOG_ERROR, "Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0) |
829 | (*op_errstr) ? *op_errstr : " ")do { do { if (0) printf ("Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 829, GF_LOG_ERROR, "Commit of operation 'Volume %s' failed on %s %s %s" , gd_op_list[op], hostname, (*op_errstr) ? ":" : " ", (*op_errstr ) ? *op_errstr : " "); } while (0); |
830 | if (*op_errstr == NULL((void*)0)) |
831 | gf_asprintf (op_errstr, OPERRSTR_COMMIT_FAIL"Commit failed on %s. Please check the log file " "for more details.", |
832 | hostname); |
833 | goto out; |
834 | } else { |
835 | glusterd_op_modify_op_ctx (op, op_ctx); |
836 | } |
837 | |
838 | if (!npeers) { |
839 | ret = 0; |
840 | goto out; |
841 | } |
842 | gd_syncargs_init (&args, op_ctx); |
843 | synctask_barrier_init((&args))syncbarrier_init (&(&args)->barrier); |
844 | peer_cnt = 0; |
845 | list_for_each_entry (peerinfo, peers, op_peers_list)for (peerinfo = ((typeof(*peerinfo) *)((char *)((peers)->next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list ))); &peerinfo->op_peers_list != (peers); peerinfo = ( (typeof(*peerinfo) *)((char *)(peerinfo->op_peers_list.next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list )))) { |
846 | ret = gd_syncop_mgmt_commit_op (peerinfo->rpc, &args, |
847 | MY_UUID(__glusterd_uuid()), tmp_uuid, |
848 | op, req_dict, op_ctx); |
849 | peer_cnt++; |
850 | } |
851 | gd_synctask_barrier_wait((&args), peer_cnt); |
852 | ret = args.op_ret; |
853 | if (dict_get_str (op_ctx, "errstr", &errstr) == 0) |
854 | *op_errstr = gf_strdup (errstr); |
855 | |
856 | out: |
857 | if (rsp_dict) |
858 | dict_unref (rsp_dict); |
859 | return ret; |
860 | } |
861 | |
862 | int |
863 | gd_unlock_op_phase (struct list_head *peers, glusterd_op_t op, int op_ret, |
864 | rpcsvc_request_t *req, dict_t *op_ctx, char *op_errstr, |
865 | int npeers) |
866 | { |
867 | glusterd_peerinfo_t *peerinfo = NULL((void*)0); |
868 | glusterd_peerinfo_t *tmp = NULL((void*)0); |
869 | uuid_t tmp_uuid = {0}; |
870 | int peer_cnt = 0; |
871 | int ret = -1; |
872 | xlator_t *this = NULL((void*)0); |
873 | struct syncargs args = {0}; |
874 | |
875 | if (!npeers) { |
876 | ret = 0; |
877 | goto out; |
878 | } |
879 | |
880 | this = THIS(*__glusterfs_this_location()); |
881 | synctask_barrier_init((&args))syncbarrier_init (&(&args)->barrier); |
882 | peer_cnt = 0; |
883 | list_for_each_entry_safe (peerinfo, tmp, peers, op_peers_list)for (peerinfo = ((typeof(*peerinfo) *)((char *)((peers)->next )-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list ))), tmp = ((typeof(*peerinfo) *)((char *)(peerinfo->op_peers_list .next)-(unsigned long)(&((typeof(*peerinfo) *)0)->op_peers_list ))); &peerinfo->op_peers_list != (peers); peerinfo = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->op_peers_list.next )-(unsigned long)(&((typeof(*tmp) *)0)->op_peers_list) ))) { |
884 | gd_syncop_mgmt_unlock (peerinfo->rpc, &args, MY_UUID(__glusterd_uuid()), tmp_uuid); |
885 | list_del_init (&peerinfo->op_peers_list); |
886 | peer_cnt++; |
887 | } |
888 | gd_synctask_barrier_wait((&args), peer_cnt); |
889 | ret = args.op_ret; |
890 | if (ret) { |
891 | gf_log (this->name, GF_LOG_ERROR, "Failed to unlock "do { do { if (0) printf ("Failed to unlock " "on some peer(s)" ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 892, GF_LOG_ERROR, "Failed to unlock " "on some peer(s)"); } while (0) |
892 | "on some peer(s)")do { do { if (0) printf ("Failed to unlock " "on some peer(s)" ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 892, GF_LOG_ERROR, "Failed to unlock " "on some peer(s)"); } while (0); |
893 | } |
894 | |
895 | out: |
896 | glusterd_op_send_cli_response (op, op_ret, 0, req, op_ctx, op_errstr); |
897 | glusterd_op_clear_op (op); |
898 | glusterd_unlock (MY_UUID(__glusterd_uuid())); |
899 | |
900 | return 0; |
901 | } |
902 | |
903 | int |
904 | gd_get_brick_count (struct list_head *bricks) |
905 | { |
906 | glusterd_pending_node_t *pending_node = NULL((void*)0); |
907 | int npeers = 0; |
908 | list_for_each_entry (pending_node, bricks, list)for (pending_node = ((typeof(*pending_node) *)((char *)((bricks )->next)-(unsigned long)(&((typeof(*pending_node) *)0) ->list))); &pending_node->list != (bricks); pending_node = ((typeof(*pending_node) *)((char *)(pending_node->list. next)-(unsigned long)(&((typeof(*pending_node) *)0)->list )))) { |
909 | npeers++; |
910 | } |
911 | return npeers; |
912 | } |
913 | |
914 | int |
915 | gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, char **op_errstr) |
916 | { |
917 | glusterd_pending_node_t *pending_node = NULL((void*)0); |
918 | struct list_head selected = {0,}; |
919 | xlator_t *this = NULL((void*)0); |
920 | int brick_count = 0; |
921 | int ret = -1; |
922 | rpc_clnt_t *rpc = NULL((void*)0); |
923 | dict_t *rsp_dict = NULL((void*)0); |
924 | glusterd_conf_t *conf = NULL((void*)0); |
925 | |
926 | this = THIS(*__glusterfs_this_location()); |
927 | conf = this->private; |
928 | rsp_dict = dict_new (); |
929 | if (!rsp_dict) { |
930 | ret = -1; |
931 | goto out; |
932 | } |
933 | |
934 | INIT_LIST_HEAD (&selected)do { (&selected)->next = (&selected)->prev = & selected; } while (0); |
935 | ret = glusterd_op_bricks_select (op, req_dict, op_errstr, &selected, rsp_dict); |
936 | if (ret) { |
937 | gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details."); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__, 939, GF_LOG_ERROR , "%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details." ); } while (0) |
938 | (*op_errstr)? *op_errstr: "Brick op failed. Check "do { do { if (0) printf ("%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details."); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__, 939, GF_LOG_ERROR , "%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details." ); } while (0) |
939 | "glusterd log file for more details.")do { do { if (0) printf ("%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details."); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__, 939, GF_LOG_ERROR , "%s", (*op_errstr)? *op_errstr: "Brick op failed. Check " "glusterd log file for more details." ); } while (0); |
940 | goto out; |
941 | } |
942 | |
943 | if (op == GD_OP_HEAL_VOLUME) { |
944 | ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx, rsp_dict); |
945 | if (ret) |
946 | goto out; |
947 | } |
948 | dict_unref (rsp_dict); |
949 | rsp_dict = NULL((void*)0); |
950 | |
951 | brick_count = 0; |
952 | list_for_each_entry (pending_node, &selected, list)for (pending_node = ((typeof(*pending_node) *)((char *)((& selected)->next)-(unsigned long)(&((typeof(*pending_node ) *)0)->list))); &pending_node->list != (&selected ); pending_node = ((typeof(*pending_node) *)((char *)(pending_node ->list.next)-(unsigned long)(&((typeof(*pending_node) * )0)->list)))) { |
953 | rpc = glusterd_pending_node_get_rpc (pending_node); |
954 | if (!rpc) { |
955 | if (pending_node->type == GD_NODE_REBALANCE) { |
956 | ret = 0; |
957 | glusterd_defrag_volume_node_rsp (req_dict, |
958 | NULL((void*)0), op_ctx); |
959 | goto out; |
960 | } |
961 | |
962 | ret = -1; |
963 | 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-syncop.c", __FUNCTION__ , 964, GF_LOG_ERROR, "Brick Op failed " "due to rpc failure." ); } while (0) |
964 | "due to rpc failure.")do { do { if (0) printf ("Brick Op failed " "due to rpc failure." ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 964, GF_LOG_ERROR, "Brick Op failed " "due to rpc failure." ); } while (0); |
965 | goto out; |
966 | } |
967 | ret = gd_syncop_mgmt_brick_op (rpc, pending_node, op, req_dict, |
968 | op_ctx, op_errstr); |
969 | if (ret) |
970 | goto out; |
971 | |
972 | brick_count++; |
973 | } |
974 | |
975 | ret = 0; |
976 | out: |
977 | if (rsp_dict) |
978 | dict_unref (rsp_dict); |
979 | gf_log (this->name, GF_LOG_DEBUG, "Sent op req to %d bricks",do { do { if (0) printf ("Sent op req to %d bricks", brick_count ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 980, GF_LOG_DEBUG, "Sent op req to %d bricks", brick_count) ; } while (0) |
980 | brick_count)do { do { if (0) printf ("Sent op req to %d bricks", brick_count ); } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 980, GF_LOG_DEBUG, "Sent op req to %d bricks", brick_count) ; } while (0); |
981 | return ret; |
982 | } |
983 | |
984 | void |
985 | gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req) |
986 | { |
987 | int ret = -1; |
988 | int npeers = 0; |
989 | dict_t *req_dict = NULL((void*)0); |
990 | glusterd_conf_t *conf = NULL((void*)0); |
991 | glusterd_op_t op = 0; |
992 | int32_t tmp_op = 0; |
993 | char *op_errstr = NULL((void*)0); |
994 | xlator_t *this = NULL((void*)0); |
995 | |
996 | this = THIS(*__glusterfs_this_location()); |
997 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd-syncop.c" , __FUNCTION__, 997, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
998 | conf = this->private; |
999 | GF_ASSERT (conf)do { if (!(conf)) { do { do { if (0) printf ("Assertion failed: " "conf"); } while (0); _gf_log_callingfn ("", "glusterd-syncop.c" , __FUNCTION__, 999, GF_LOG_ERROR, "Assertion failed: " "conf" ); } while (0); } } while (0); |
1000 | |
1001 | ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY"sync-mgmt-operation", &tmp_op); |
1002 | if (ret) { |
1003 | gf_log (this->name, GF_LOG_ERROR, "Failed to get volume "do { do { if (0) printf ("Failed to get volume " "operation") ; } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 1004, GF_LOG_ERROR, "Failed to get volume " "operation"); } while (0) |
1004 | "operation")do { do { if (0) printf ("Failed to get volume " "operation") ; } while (0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 1004, GF_LOG_ERROR, "Failed to get volume " "operation"); } while (0); |
1005 | goto out; |
1006 | } |
1007 | |
1008 | op = tmp_op; |
1009 | ret = glusterd_lock (MY_UUID(__glusterd_uuid())); |
1010 | if (ret) { |
1011 | gf_log (this->name, GF_LOG_ERROR, "Unable to acquire lock")do { do { if (0) printf ("Unable to acquire lock"); } while ( 0); _gf_log (this->name, "glusterd-syncop.c", __FUNCTION__ , 1011, GF_LOG_ERROR, "Unable to acquire lock"); } while (0); |
1012 | gf_asprintf (&op_errstr, "Another transaction is in progress. " |
1013 | "Please try again after sometime."); |
1014 | goto out; |
1015 | } |
1016 | |
1017 | /* storing op globally to access in synctask code paths |
1018 | * This is still acceptable, as we are performing this under |
1019 | * the 'cluster' lock*/ |
1020 | glusterd_op_set_op (op); |
1021 | INIT_LIST_HEAD (&conf->xaction_peers)do { (&conf->xaction_peers)->next = (&conf-> xaction_peers)->prev = &conf->xaction_peers; } while (0); |
1022 | npeers = gd_build_peers_list (&conf->peers, &conf->xaction_peers, op); |
1023 | |
1024 | ret = gd_lock_op_phase (&conf->xaction_peers, op, op_ctx, &op_errstr, npeers); |
1025 | if (ret) |
1026 | goto out; |
1027 | |
1028 | ret = glusterd_op_build_payload (&req_dict, &op_errstr, op_ctx); |
1029 | if (ret) { |
1030 | gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD,do { do { if (0) printf ("Failed to build payload for operation 'Volume %s'" , gd_op_list[op]); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 1031, GF_LOG_ERROR, "Failed to build payload for operation 'Volume %s'" , gd_op_list[op]); } while (0) |
1031 | gd_op_list[op])do { do { if (0) printf ("Failed to build payload for operation 'Volume %s'" , gd_op_list[op]); } while (0); _gf_log (this->name, "glusterd-syncop.c" , __FUNCTION__, 1031, GF_LOG_ERROR, "Failed to build payload for operation 'Volume %s'" , gd_op_list[op]); } while (0); |
1032 | if (op_errstr == NULL((void*)0)) |
1033 | gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD"Failed to build payload. Please check the log " "file for more details."); |
1034 | goto out; |
1035 | } |
1036 | |
1037 | ret = gd_stage_op_phase (&conf->xaction_peers, op, op_ctx, req_dict, |
1038 | &op_errstr, npeers); |
1039 | if (ret) |
1040 | goto out; |
1041 | |
1042 | ret = gd_brick_op_phase (op, op_ctx, req_dict, &op_errstr); |
1043 | if (ret) |
1044 | goto out; |
1045 | |
1046 | ret = gd_commit_op_phase (&conf->xaction_peers, op, op_ctx, req_dict, |
1047 | &op_errstr, npeers); |
1048 | if (ret) |
1049 | goto out; |
1050 | |
1051 | ret = 0; |
1052 | out: |
1053 | (void) gd_unlock_op_phase (&conf->xaction_peers, op, ret, req, |
1054 | op_ctx, op_errstr, npeers); |
1055 | |
1056 | if (req_dict) |
1057 | dict_unref (req_dict); |
1058 | |
1059 | if (op_errstr) |
1060 | GF_FREE (op_errstr)__gf_free (op_errstr); |
1061 | |
1062 | return; |
1063 | } |
1064 | |
1065 | int32_t |
1066 | glusterd_op_begin_synctask (rpcsvc_request_t *req, glusterd_op_t op, |
1067 | void *dict) |
1068 | { |
1069 | int ret = 0; |
1070 | |
1071 | ret = dict_set_int32 (dict, GD_SYNC_OPCODE_KEY"sync-mgmt-operation", op); |
1072 | if (ret) { |
1073 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("dict set failed for setting operations" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "glusterd-syncop.c", __FUNCTION__, 1074, GF_LOG_ERROR, "dict set failed for setting operations" ); } while (0) |
1074 | "dict set failed for setting operations")do { do { if (0) printf ("dict set failed for setting operations" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "glusterd-syncop.c", __FUNCTION__, 1074, GF_LOG_ERROR, "dict set failed for setting operations" ); } while (0); |
1075 | goto out; |
1076 | } |
1077 | |
1078 | gd_sync_task_begin (dict, req); |
1079 | ret = 0; |
1080 | out: |
1081 | |
1082 | return ret; |
1083 | } |