diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2015-05-20 14:33:41 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-06-01 02:23:26 -0700 |
commit | 823da7104b4725469a597920d0171a21ff9ff707 (patch) | |
tree | f7e7c7136b5bcb4c7560b3f9f36d4528904fa1fd | |
parent | 99ab3637b2b457c866a46a7d109b09e2d4a23e5d (diff) |
glusterd : allocate peerid to store in frame->cookie
Backport of http://review.gluster.org/10842
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: 1223215
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>
(cherry picked from commit 37f365843bed87728048da1f56de22290f5cb70f)
Reviewed-on: http://review.gluster.org/10959
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 56 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.c | 70 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.h | 10 |
3 files changed, 94 insertions, 42 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index a3eaf2ebdcd..954ff039085 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -341,6 +341,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); @@ -366,7 +368,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); @@ -383,9 +385,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, @@ -620,6 +624,7 @@ out: if (rsp.op_errstr) free (rsp.op_errstr); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -644,7 +649,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); @@ -661,9 +666,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, @@ -879,6 +886,7 @@ out: if (rsp.dict.dict_val) free (rsp.dict.dict_val); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -903,7 +911,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); @@ -920,9 +928,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, @@ -1122,7 +1132,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); @@ -1147,7 +1157,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); @@ -1164,9 +1174,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, @@ -1345,6 +1357,7 @@ out: if (rsp.dict.dict_val) free (rsp.dict.dict_val); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -1369,7 +1382,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); @@ -1387,9 +1400,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, @@ -1558,6 +1573,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); @@ -1582,7 +1598,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); @@ -1599,9 +1615,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, diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 2ac947fd710..d7d75bbc1f1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -322,7 +322,7 @@ out: int32_t gd_syncop_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov, - int count, void *myframe) + int count, void *myframe) { int ret = -1; struct syncargs *args = NULL; @@ -366,6 +366,8 @@ out: gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, GLUSTERD_MGMT_V3_LOCK, *peerid, rsp.uuid); + GF_FREE (peerid); + STACK_DESTROY (frame->root); synctask_barrier_wake(args); return 0; @@ -388,7 +390,7 @@ gd_syncop_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx, int ret = -1; gd1_mgmt_v3_lock_req req = {{0},}; glusterd_conf_t *conf = THIS->private; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; GF_ASSERT(op_ctx); GF_ASSERT(peerinfo); @@ -404,9 +406,11 @@ gd_syncop_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx, gf_uuid_copy (req.txn_id, txn_id); 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_syncop_mgmt_v3_lock_cbk, @@ -463,6 +467,8 @@ out: gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, GLUSTERD_MGMT_V3_UNLOCK, *peerid, rsp.uuid); + GF_FREE (peerid); + STACK_DESTROY (frame->root); synctask_barrier_wake(args); return 0; @@ -484,7 +490,7 @@ gd_syncop_mgmt_v3_unlock (dict_t *op_ctx, glusterd_peerinfo_t *peerinfo, int ret = -1; gd1_mgmt_v3_unlock_req req = {{0},}; glusterd_conf_t *conf = THIS->private; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; GF_ASSERT(op_ctx); GF_ASSERT(peerinfo); @@ -499,9 +505,11 @@ gd_syncop_mgmt_v3_unlock (dict_t *op_ctx, glusterd_peerinfo_t *peerinfo, gf_uuid_copy (req.uuid, my_uuid); gf_uuid_copy (req.txn_id, txn_id); - 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_syncop_mgmt_v3_unlock_cbk, @@ -569,6 +577,8 @@ out: gd_collate_errors (args, op_ret, op_errno, NULL, GLUSTERD_MGMT_CLUSTER_LOCK, *peerid, rsp.uuid); + GF_FREE (peerid); + STACK_DESTROY (frame->root); synctask_barrier_wake(args); return 0; @@ -589,16 +599,19 @@ gd_syncop_mgmt_lock (glusterd_peerinfo_t *peerinfo, struct syncargs *args, int ret = -1; gd1_mgmt_cluster_lock_req req = {{0},}; glusterd_conf_t *conf = THIS->private; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; gf_uuid_copy (req.uuid, my_uuid); - 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_prog, GLUSTERD_MGMT_CLUSTER_LOCK, gd_syncop_mgmt_lock_cbk, (xdrproc_t) xdr_gd1_mgmt_cluster_lock_req); +out: return ret; } @@ -657,6 +670,8 @@ out: gd_collate_errors (args, op_ret, op_errno, NULL, GLUSTERD_MGMT_CLUSTER_UNLOCK, *peerid, rsp.uuid); + GF_FREE (peerid); + STACK_DESTROY (frame->root); synctask_barrier_wake(args); return 0; @@ -678,16 +693,19 @@ gd_syncop_mgmt_unlock (glusterd_peerinfo_t *peerinfo, struct syncargs *args, int ret = -1; gd1_mgmt_cluster_unlock_req req = {{0},}; glusterd_conf_t *conf = THIS->private; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; gf_uuid_copy (req.uuid, my_uuid); - 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_prog, GLUSTERD_MGMT_CLUSTER_UNLOCK, gd_syncop_mgmt_unlock_cbk, (xdrproc_t) xdr_gd1_mgmt_cluster_lock_req); +out: return ret; } @@ -779,6 +797,7 @@ out: if (rsp_dict) dict_unref (rsp_dict); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -802,7 +821,7 @@ gd_syncop_mgmt_stage_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args, gd1_mgmt_stage_op_req *req = NULL; glusterd_conf_t *conf = THIS->private; int ret = -1; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_stage_req_t); if (!req) @@ -816,9 +835,11 @@ gd_syncop_mgmt_stage_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args, if (ret) goto out; - 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_prog, GLUSTERD_MGMT_STAGE_OP, gd_syncop_stage_op_cbk, (xdrproc_t) xdr_gd1_mgmt_stage_op_req); @@ -1058,6 +1079,7 @@ out: GLUSTERD_MGMT_COMMIT_OP, *peerid, rsp.uuid); if (rsp_dict) dict_unref (rsp_dict); + GF_FREE (peerid); STACK_DESTROY (frame->root); synctask_barrier_wake(args); @@ -1082,7 +1104,7 @@ gd_syncop_mgmt_commit_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args, glusterd_conf_t *conf = THIS->private; gd1_mgmt_commit_op_req *req = NULL; int ret = -1; - uuid_t peerid = {0,}; + uuid_t *peerid = NULL; req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_commit_req_t); if (!req) @@ -1096,9 +1118,11 @@ gd_syncop_mgmt_commit_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args, if (ret) goto out; - 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_prog, GLUSTERD_MGMT_COMMIT_OP, gd_syncop_commit_op_cbk, (xdrproc_t) xdr_gd1_mgmt_commit_op_req); @@ -1840,14 +1864,14 @@ local_locking_done: out: op_ret = ret; if (txn_id) { - if (volname) - (void) gd_unlock_op_phase (conf, op, &op_ret, req, op_ctx, - op_errstr, volname, is_acquired, - *txn_id, &txn_opinfo); if (global) (void) gd_unlock_op_phase (conf, op, &op_ret, req, op_ctx, op_errstr, global, is_acquired, *txn_id, &txn_opinfo); + else + (void) gd_unlock_op_phase (conf, op, &op_ret, req, op_ctx, + op_errstr, volname, is_acquired, + *txn_id, &txn_opinfo); /* Clearing the transaction opinfo */ diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.h b/xlators/mgmt/glusterd/src/glusterd-syncop.h index 87a3c76f9fb..c8303a04d5e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.h +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.h @@ -36,6 +36,16 @@ synclock_lock (&conf->big_lock); \ } while (0) +#define GD_ALLOC_COPY_UUID(dst_ptr, uuid, ret) do { \ + dst_ptr = GF_CALLOC (1, sizeof (*dst_ptr), gf_common_mt_uuid_t); \ + if (dst_ptr) { \ + gf_uuid_copy (*dst_ptr, uuid); \ + ret = 0; \ + } else { \ + ret = -1; \ + } \ +} while (0) + int gd_syncop_submit_request (struct rpc_clnt *rpc, void *req, void *local, void *cookie, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc); |