summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2015-04-10 13:02:59 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-04-26 23:47:01 -0700
commita1de3b05b3fd7514dbce5182c371c6be97819969 (patch)
tree0f450b6faa2ccea4cee364d9094be67c3ded3c1b /xlators/mgmt/glusterd
parent585b1f0d9e485674268cb90bd8f3fdb143bab06b (diff)
glusterd: Remove direct references to peerinfo in frame cookies
RCU protection requires that we don't have direct references to protected data structures outside read-critical sections This change was developed on the git branch at [1]. This commit is a combination of the following commits on the development branch. 82ebfdd Remove direct references to peerinfo in frame cookies dec4bec Remove incorrect and unneeded code from gd_syncop_mgmt_v3_unlock_cbk_fn 7aced7b Use stack allocated uuid for frame cookie. 38e4124 Address comments from 10192/2 [1]: https://github.com/kshlm/glusterfs/tree/urcu Change-Id: Ic50e5fca0be72af5090f4cf318efa55d29075de9 BUG: 1205186 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/10192 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c91
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c130
3 files changed, 158 insertions, 67 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index 4e4dd047281..e07d4100d00 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -28,8 +28,8 @@ extern struct rpc_clnt_program gd_mgmt_v3_prog;
void
gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
- char *op_errstr, int op_code,
- glusterd_peerinfo_t *peerinfo, u_char *uuid)
+ char *op_errstr, int op_code, uuid_t peerid,
+ u_char *uuid)
{
char *peer_str = NULL;
char err_str[PATH_MAX] = "Please check log file for details.";
@@ -39,6 +39,7 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
int is_operrstr_blk = 0;
char *err_string = NULL;
char *cli_err_str = NULL;
+ glusterd_peerinfo_t *peerinfo = NULL;
this = THIS;
GF_ASSERT (this);
@@ -49,10 +50,14 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
args->op_ret = op_ret;
args->op_errno = op_errno;
+ rcu_read_lock ();
+ peerinfo = glusterd_peerinfo_find (peerid, NULL);
if (peerinfo)
- peer_str = peerinfo->hostname;
+ peer_str = gf_strdup (peerinfo->hostname);
else
- peer_str = uuid_utoa (uuid);
+ peer_str = gf_strdup (uuid_utoa (uuid));
+
+ rcu_read_unlock ();
is_operrstr_blk = (op_errstr && strcmp (op_errstr, ""));
err_string = (is_operrstr_blk) ? op_errstr : err_str;
@@ -129,6 +134,8 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
args->errstr = gf_strdup (err_str);
}
+ GF_FREE (peer_str);
+
return;
}
@@ -285,6 +292,7 @@ gd_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_ret = -1;
int32_t op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -301,7 +309,7 @@ gd_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
*/
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -325,8 +333,7 @@ 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,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_LOCK, *peerid, rsp.uuid);
if (rsp.dict.dict_val)
free (rsp.dict.dict_val);
STACK_DESTROY (frame->root);
@@ -352,6 +359,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,};
this = THIS;
GF_ASSERT (this);
@@ -367,9 +375,12 @@ 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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_v3_prog,
GLUSTERD_MGMT_V3_LOCK,
gd_mgmt_v3_lock_cbk,
@@ -525,6 +536,7 @@ gd_mgmt_v3_pre_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_errno = -1;
dict_t *rsp_dict = NULL;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -533,7 +545,7 @@ gd_mgmt_v3_pre_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -594,7 +606,7 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
GLUSTERD_MGMT_V3_PRE_VALIDATE,
- peerinfo, rsp.uuid);
+ *peerid, rsp.uuid);
if (rsp.op_errstr)
free (rsp.op_errstr);
@@ -622,6 +634,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,};
this = THIS;
GF_ASSERT (this);
@@ -637,9 +650,12 @@ 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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ 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,
@@ -807,6 +823,7 @@ gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_ret = -1;
int32_t op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -815,7 +832,7 @@ gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -843,8 +860,8 @@ gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov,
out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
- GLUSTERD_MGMT_V3_BRICK_OP,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_BRICK_OP, *peerid,
+ rsp.uuid);
if (rsp.op_errstr)
free (rsp.op_errstr);
@@ -875,6 +892,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,};
this = THIS;
GF_ASSERT (this);
@@ -890,9 +908,12 @@ 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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ 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,
@@ -1019,6 +1040,7 @@ gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_errno = -1;
dict_t *rsp_dict = NULL;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -1027,7 +1049,7 @@ gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -1087,8 +1109,8 @@ out:
dict_unref (rsp_dict);
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
- GLUSTERD_MGMT_V3_COMMIT,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_COMMIT, *peerid, rsp.uuid);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
@@ -1113,6 +1135,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,};
this = THIS;
GF_ASSERT (this);
@@ -1128,9 +1151,12 @@ 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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_v3_prog,
GLUSTERD_MGMT_V3_COMMIT,
gd_mgmt_v3_commit_cbk,
@@ -1266,6 +1292,7 @@ gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_ret = -1;
int32_t op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -1274,7 +1301,7 @@ gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -1298,13 +1325,14 @@ gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
- GLUSTERD_MGMT_V3_POST_VALIDATE,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_POST_VALIDATE, *peerid,
+ rsp.uuid);
if (rsp.op_errstr)
free (rsp.op_errstr);
if (rsp.dict.dict_val)
free (rsp.dict.dict_val);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -1328,6 +1356,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,};
this = THIS;
GF_ASSERT (this);
@@ -1344,9 +1373,12 @@ gd_mgmt_v3_post_validate_req (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx,
gf_uuid_copy (req.uuid, my_uuid);
req.op = op;
req.op_ret = op_ret;
+
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ 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,
@@ -1477,6 +1509,7 @@ gd_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int32_t op_ret = -1;
int32_t op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -1485,7 +1518,7 @@ gd_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -1509,10 +1542,10 @@ gd_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
- GLUSTERD_MGMT_V3_UNLOCK,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_UNLOCK, *peerid, rsp.uuid);
if (rsp.dict.dict_val)
free (rsp.dict.dict_val);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -1536,6 +1569,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,};
this = THIS;
GF_ASSERT (this);
@@ -1551,9 +1585,12 @@ 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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ 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-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-mgmt.h
index ab9265c75c4..894bd198ff3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.h
@@ -16,8 +16,8 @@
#endif
void gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
- char *op_errstr, int op_code,
- glusterd_peerinfo_t *peerinfo, u_char *uuid);
+ char *op_errstr, int op_code, uuid_t peerid,
+ u_char *uuid);
int32_t
gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict,
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index 663b0a73875..ee8f1eadf2e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -39,22 +39,25 @@ gd_synctask_barrier_wait (struct syncargs *args, int count)
static void
gd_collate_errors (struct syncargs *args, int op_ret, int op_errno,
- char *op_errstr, int op_code,
- glusterd_peerinfo_t *peerinfo, u_char *uuid)
+ char *op_errstr, int op_code, uuid_t peerid, u_char *uuid)
{
char err_str[PATH_MAX] = "Please check log file for details.";
char op_err[PATH_MAX] = "";
int len = -1;
char *peer_str = NULL;
+ glusterd_peerinfo_t *peerinfo = NULL;
if (op_ret) {
args->op_ret = op_ret;
args->op_errno = op_errno;
+ rcu_read_lock ();
+ peerinfo = glusterd_peerinfo_find (peerid, NULL);
if (peerinfo)
- peer_str = peerinfo->hostname;
+ peer_str = gf_strdup (peerinfo->hostname);
else
- peer_str = uuid_utoa (uuid);
+ peer_str = gf_strdup (uuid_utoa (uuid));
+ rcu_read_unlock ();
if (op_errstr && strcmp (op_errstr, "")) {
len = snprintf (err_str, sizeof(err_str) - 1,
@@ -109,6 +112,8 @@ gd_collate_errors (struct syncargs *args, int op_ret, int op_errno,
args->errstr = gf_strdup (err_str);
}
+ GF_FREE (peer_str);
+
return;
}
@@ -327,6 +332,7 @@ gd_syncop_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int op_ret = -1;
int op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -335,7 +341,7 @@ gd_syncop_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -358,8 +364,8 @@ gd_syncop_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
op_errno = rsp.op_errno;
out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
- GLUSTERD_MGMT_V3_LOCK,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_LOCK, *peerid, rsp.uuid);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -382,6 +388,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,};
GF_ASSERT(op_ctx);
GF_ASSERT(peerinfo);
@@ -396,8 +403,11 @@ gd_syncop_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx,
gf_uuid_copy (req.uuid, my_uuid);
gf_uuid_copy (req.txn_id, txn_id);
req.op = op;
+
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_v3_prog,
GLUSTERD_MGMT_V3_LOCK,
gd_syncop_mgmt_v3_lock_cbk,
@@ -421,6 +431,7 @@ gd_syncop_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int op_ret = -1;
int op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
@@ -429,7 +440,7 @@ gd_syncop_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -448,15 +459,12 @@ gd_syncop_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
gf_uuid_copy (args->uuid, rsp.uuid);
- /* Set peer as locked, so we unlock only the locked peers */
- if (rsp.op_ret == 0)
- peerinfo->locked = _gf_true;
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
- GLUSTERD_MGMT_V3_UNLOCK,
- peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_V3_UNLOCK, *peerid, rsp.uuid);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -478,6 +486,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,};
GF_ASSERT(op_ctx);
GF_ASSERT(peerinfo);
@@ -491,8 +500,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);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_v3_prog,
GLUSTERD_MGMT_V3_UNLOCK,
gd_syncop_mgmt_v3_unlock_cbk,
@@ -516,13 +528,14 @@ _gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov,
int op_ret = -1;
int op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
frame->cookie = NULL;
@@ -541,14 +554,25 @@ _gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov,
gf_uuid_copy (args->uuid, rsp.uuid);
- /* Set peer as locked, so we unlock only the locked peers */
- if (rsp.op_ret == 0)
- peerinfo->locked = _gf_true;
+ rcu_read_lock ();
+ peerinfo = glusterd_peerinfo_find (*peerid, NULL);
+ if (peerinfo) {
+ /* Set peer as locked, so we unlock only the locked peers */
+ if (rsp.op_ret == 0)
+ peerinfo->locked = _gf_true;
+ } else {
+ rsp.op_ret = -1;
+ gf_log (this->name, GF_LOG_ERROR, "Could not find peer with "
+ "ID %s", uuid_utoa (*peerid));
+ }
+ rcu_read_unlock ();
+
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, NULL,
- GLUSTERD_MGMT_CLUSTER_LOCK, peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_CLUSTER_LOCK, *peerid, rsp.uuid);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -569,10 +593,13 @@ 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,};
gf_uuid_copy (req.uuid, my_uuid);
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_prog,
GLUSTERD_MGMT_CLUSTER_LOCK,
gd_syncop_mgmt_lock_cbk,
@@ -593,14 +620,16 @@ _gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov,
int op_ret = -1;
int op_errno = -1;
xlator_t *this = NULL;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
+ frame->cookie = NULL;
if (-1 == req->rpc_status) {
op_errno = ENOTCONN;
@@ -617,12 +646,23 @@ _gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov,
gf_uuid_copy (args->uuid, rsp.uuid);
- peerinfo->locked = _gf_false;
+ rcu_read_lock ();
+ peerinfo = glusterd_peerinfo_find (*peerid, NULL);
+ if (peerinfo) {
+ peerinfo->locked = _gf_false;
+ } else {
+ rsp.op_ret = -1;
+ gf_log (this->name, GF_LOG_ERROR, "Could not find peer with "
+ "ID %s", uuid_utoa (*peerid));
+ }
+ rcu_read_unlock ();
+
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, NULL,
- GLUSTERD_MGMT_CLUSTER_UNLOCK, peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_CLUSTER_UNLOCK, *peerid, rsp.uuid);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -644,10 +684,13 @@ 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,};
gf_uuid_copy (req.uuid, my_uuid);
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, peerinfo,
+ ret = gd_syncop_submit_request (peerinfo->rpc, &req, args, &peerid,
&gd_mgmt_prog,
GLUSTERD_MGMT_CLUSTER_UNLOCK,
gd_syncop_mgmt_unlock_cbk,
@@ -666,17 +709,18 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
xlator_t *this = NULL;
dict_t *rsp_dict = NULL;
call_frame_t *frame = NULL;
- glusterd_peerinfo_t *peerinfo = NULL;
int op_ret = -1;
int op_errno = -1;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
+ frame->cookie = NULL;
if (-1 == req->rpc_status) {
op_errno = ENOTCONN;
@@ -706,8 +750,10 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
}
}
- peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL);
- if (peerinfo == NULL) {
+ rcu_read_lock ();
+ ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == NULL);
+ rcu_read_unlock ();
+ if (ret) {
ret = -1;
gf_log (this->name, GF_LOG_CRITICAL, "Staging response "
"for 'Volume %s' received from unknown "
@@ -737,7 +783,7 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
out:
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
- GLUSTERD_MGMT_STAGE_OP, peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_STAGE_OP, *peerid, rsp.uuid);
if (rsp_dict)
dict_unref (rsp_dict);
@@ -764,6 +810,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,};
req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_stage_req_t);
if (!req)
@@ -777,8 +824,10 @@ gd_syncop_mgmt_stage_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args,
if (ret)
goto out;
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, req, args, peerinfo,
+ 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);
@@ -933,18 +982,19 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
xlator_t *this = NULL;
dict_t *rsp_dict = NULL;
call_frame_t *frame = NULL;
- glusterd_peerinfo_t *peerinfo = NULL;
int op_ret = -1;
int op_errno = -1;
int type = GF_QUOTA_OPTION_TYPE_NONE;
+ uuid_t *peerid = NULL;
this = THIS;
GF_ASSERT (this);
frame = myframe;
args = frame->local;
- peerinfo = frame->cookie;
+ peerid = frame->cookie;
frame->local = NULL;
+ frame->cookie = NULL;
if (-1 == req->rpc_status) {
op_errno = ENOTCONN;
@@ -975,9 +1025,10 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
}
}
- peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL);
-
- if (peerinfo == NULL) {
+ rcu_read_lock ();
+ ret = (glusterd_peerinfo_find (rsp.uuid, NULL) == 0);
+ rcu_read_unlock ();
+ if (ret) {
ret = -1;
gf_log (this->name, GF_LOG_CRITICAL, "Commit response "
"for 'Volume %s' received from unknown "
@@ -1014,7 +1065,7 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
out:
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
- GLUSTERD_MGMT_COMMIT_OP, peerinfo, rsp.uuid);
+ GLUSTERD_MGMT_COMMIT_OP, *peerid, rsp.uuid);
if (rsp_dict)
dict_unref (rsp_dict);
@@ -1041,6 +1092,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,};
req = GF_CALLOC (1, sizeof (*req), gf_gld_mt_mop_commit_req_t);
if (!req)
@@ -1054,8 +1106,10 @@ gd_syncop_mgmt_commit_op (glusterd_peerinfo_t *peerinfo, struct syncargs *args,
if (ret)
goto out;
+ gf_uuid_copy (peerid, peerinfo->uuid);
+
synclock_unlock (&conf->big_lock);
- ret = gd_syncop_submit_request (peerinfo->rpc, req, args, peerinfo,
+ 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);