diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2015-05-20 14:33:41 +0530 |
---|---|---|
committer | Kaushal M <kaushal@redhat.com> | 2015-05-28 00:09:43 -0700 |
commit | 37f365843bed87728048da1f56de22290f5cb70f (patch) | |
tree | 1c5b8a23c016b0ac2f348faf6f856b1f5ea8565b /xlators/mgmt/glusterd/src/glusterd-mgmt.c | |
parent | 58a687a8e0967393428bc5f93f0d32bbc3792f88 (diff) |
glusterd : allocate peerid to store in frame->cookie
commit a1de3b05 was using peerid from the stack and storing it in the
frame->cookie and in the subsequent callback it was referred. The existance of
this variable is not guranteed in the cbk since its not dynamically allocated.
Fix is to dynmacially manage peerid in the frame cookie.
This patch also fixes one problem in gd_sync_task_begin () where unlock is not
triggered if the cluster is running with lesser than 3.6 op-version resulting into
commands failing with another transaction is in progress.
Change-Id: I0d22cf663df53ef3769585703944577461061312
BUG: 1223213
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/10842
Tested-by: NetBSD Build System
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 85d8c777884..2a362fa0007 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -340,6 +340,8 @@ gd_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov, out: gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, GLUSTERD_MGMT_V3_LOCK, *peerid, rsp.uuid); + GF_FREE (peerid); + if (rsp.dict.dict_val) free (rsp.dict.dict_val); STACK_DESTROY (frame->root); @@ -365,7 +367,7 @@ gd_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx, glusterd_conf_t *conf = THIS->private; int32_t ret = -1; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; this = THIS; GF_ASSERT (this); @@ -382,9 +384,11 @@ gd_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.uuid, my_uuid); req.op = op; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_LOCK, gd_mgmt_v3_lock_cbk, @@ -618,6 +622,7 @@ out: if (rsp.op_errstr) free (rsp.op_errstr); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -642,7 +647,7 @@ gd_mgmt_v3_pre_validate_req (glusterd_op_t op, dict_t *op_ctx, gd1_mgmt_v3_pre_val_req req = {{0},}; glusterd_conf_t *conf = THIS->private; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; this = THIS; GF_ASSERT (this); @@ -659,9 +664,11 @@ gd_mgmt_v3_pre_validate_req (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.uuid, my_uuid); req.op = op; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_PRE_VALIDATE, gd_mgmt_v3_pre_validate_cbk, @@ -877,6 +884,7 @@ out: if (rsp.dict.dict_val) free (rsp.dict.dict_val); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -901,7 +909,7 @@ gd_mgmt_v3_brick_op_req (glusterd_op_t op, dict_t *op_ctx, gd1_mgmt_v3_brick_op_req req = {{0},}; glusterd_conf_t *conf = THIS->private; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = {0,}; this = THIS; GF_ASSERT (this); @@ -918,9 +926,11 @@ gd_mgmt_v3_brick_op_req (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.uuid, my_uuid); req.op = op; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_BRICK_OP, gd_mgmt_v3_brick_op_cbk, @@ -1120,7 +1130,7 @@ out: gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_COMMIT, *peerid, rsp.uuid); - + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -1145,7 +1155,7 @@ gd_mgmt_v3_commit_req (glusterd_op_t op, dict_t *op_ctx, gd1_mgmt_v3_commit_req req = {{0},}; glusterd_conf_t *conf = THIS->private; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; this = THIS; GF_ASSERT (this); @@ -1162,9 +1172,11 @@ gd_mgmt_v3_commit_req (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.uuid, my_uuid); req.op = op; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_COMMIT, gd_mgmt_v3_commit_cbk, @@ -1343,6 +1355,7 @@ out: if (rsp.dict.dict_val) free (rsp.dict.dict_val); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -1367,7 +1380,7 @@ gd_mgmt_v3_post_validate_req (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx, gd1_mgmt_v3_post_val_req req = {{0},}; glusterd_conf_t *conf = THIS->private; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; this = THIS; GF_ASSERT (this); @@ -1385,9 +1398,11 @@ gd_mgmt_v3_post_validate_req (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx, req.op = op; req.op_ret = op_ret; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_POST_VALIDATE, gd_mgmt_v3_post_validate_cbk, @@ -1556,6 +1571,7 @@ out: GLUSTERD_MGMT_V3_UNLOCK, *peerid, rsp.uuid); if (rsp.dict.dict_val) free (rsp.dict.dict_val); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -1580,7 +1596,7 @@ gd_mgmt_v3_unlock (glusterd_op_t op, dict_t *op_ctx, gd1_mgmt_v3_unlock_req req = {{0},}; glusterd_conf_t *conf = THIS->private; xlator_t *this = NULL; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; this = THIS; GF_ASSERT (this); @@ -1597,9 +1613,11 @@ gd_mgmt_v3_unlock (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.uuid, my_uuid); req.op = op; - gf_uuid_copy (peerid, peerinfo->uuid); + GD_ALLOC_COPY_UUID (peerid, peerinfo->uuid, ret); + if (ret) + goto out; - ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid, + ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerid, &gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_UNLOCK, gd_mgmt_v3_unlock_cbk, |