summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-mgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c459
1 files changed, 305 insertions, 154 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index e24faa0be..1e5353591 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -25,13 +25,20 @@ extern struct rpc_clnt_program gd_mgmt_v3_prog;
static 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,
+ glusterd_peerinfo_t *peerinfo, 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;
+ char *peer_str = NULL;
+ char err_str[PATH_MAX] = "Please check log file for details.";
+ char op_err[PATH_MAX] = "";
+ int32_t len = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (args);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (uuid);
if (op_ret) {
args->op_ret = op_ret;
@@ -105,7 +112,7 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
"%s", op_err);
err_str[len] = '\0';
- gf_log ("", GF_LOG_ERROR, "%s", op_err);
+ gf_log (this->name, GF_LOG_ERROR, "%s", op_err);
args->errstr = gf_strdup (err_str);
}
@@ -114,32 +121,52 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno,
int32_t
gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict,
- char **op_errstr, dict_t *rsp_dict)
+ char **op_errstr, dict_t *rsp_dict)
{
- int ret = -1;
- xlator_t *this = THIS;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (rsp_dict);
switch (op) {
case GD_OP_SNAP:
{
ret = glusterd_snapshot_prevalidate (dict, op_errstr,
rsp_dict);
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Snapshot Prevalidate Failed");
+ goto out;
+ }
+
break;
}
default:
break;
}
+ ret = 0;
+out:
gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret);
return ret;
}
int32_t
gd_mgmt_v3_brick_op_fn (glusterd_op_t op, dict_t *dict,
- char **op_errstr, dict_t *rsp_dict)
+ char **op_errstr, dict_t *rsp_dict)
{
- int ret = -1;
- xlator_t *this = THIS;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (rsp_dict);
switch (op) {
case GD_OP_SNAP:
@@ -155,6 +182,7 @@ gd_mgmt_v3_brick_op_fn (glusterd_op_t op, dict_t *dict,
default:
break;
}
+
ret = 0;
out:
gf_log (this->name, GF_LOG_TRACE, "OP = %d. Returning %d", op, ret);
@@ -163,24 +191,33 @@ out:
int32_t
gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict,
- char **op_errstr, dict_t *rsp_dict)
+ char **op_errstr, dict_t *rsp_dict)
{
- int ret = -1;
- xlator_t *this = THIS;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (rsp_dict);
switch (op) {
case GD_OP_SNAP:
{
ret = glusterd_snapshot (dict, op_errstr, rsp_dict);
- if (ret)
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Snapshot Commit Failed");
goto out;
+ }
break;
}
default:
break;
}
- ret = 0;
+ ret = 0;
out:
gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret);
return ret;
@@ -188,12 +225,16 @@ out:
int32_t
gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
- char **op_errstr, dict_t *rsp_dict)
+ char **op_errstr, dict_t *rsp_dict)
{
- int ret = -1;
- xlator_t *this = THIS;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ this = THIS;
GF_ASSERT (this);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (rsp_dict);
switch (op) {
case GD_OP_SNAP:
@@ -223,16 +264,19 @@ int32_t
gd_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_lock_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
/* Even though the lock command has failed, while collating the errors
(gd_mgmt_v3_collate_errors), args->op_ret and args->op_errno will be
@@ -254,7 +298,7 @@ gd_mgmt_v3_lock_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
goto out;
}
@@ -273,6 +317,7 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_LOCK,
peerinfo, rsp.uuid);
+ free (rsp.dict.dict_val);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -292,13 +337,16 @@ gd_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx,
struct syncargs *args, uuid_t my_uuid,
uuid_t recv_uuid)
{
- int ret = -1;
gd1_mgmt_v3_lock_req req = {{0},};
glusterd_conf_t *conf = THIS->private;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -316,31 +364,38 @@ gd_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_lock_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
int
glusterd_mgmt_v3_initiate_lockdown (glusterd_conf_t *conf, glusterd_op_t op,
- dict_t *dict, char **op_errstr, int npeers,
- gf_boolean_t *is_acquired)
+ dict_t *dict, char **op_errstr, int npeers,
+ gf_boolean_t *is_acquired)
{
- int ret = -1;
- int peer_cnt = 0;
char *volname = NULL;
- uuid_t peer_uuid = {0};
- xlator_t *this = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
struct syncargs args = {0};
struct list_head *peers = NULL;
+ uuid_t peer_uuid = {0};
+ xlator_t *this = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (is_acquired);
+
peers = &conf->xaction_peers;
/* Trying to acquire multiple mgmt_v3 locks on local node */
ret = glusterd_multiple_mgmt_v3_lock (dict, MY_UUID);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"Failed to acquire mgmt_v3 locks on localhost");
goto out;
}
@@ -379,11 +434,11 @@ out:
if (volname)
ret = gf_asprintf (op_errstr,
"Another transaction is in progress "
- "for %s. Please try again after sometime.",
- volname);
+ "for %s. Please try again after "
+ "sometime.", volname);
else
ret = gf_asprintf (op_errstr,
- "Another transaction is in progress. "
+ "Another transaction is in progress "
"Please try again after sometime.");
if (ret == -1)
@@ -398,17 +453,27 @@ out:
int
glusterd_pre_validate_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
{
- int ret = 0;
+ int32_t ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (aggr);
+ GF_ASSERT (rsp);
switch (op) {
case GD_OP_SNAP:
ret = glusterd_snap_pre_validate_use_rsp_dict (aggr, rsp);
- if (ret)
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to aggregate prevalidate "
+ "response dictionaries.");
goto out;
+ }
break;
default:
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Invalid op (%s)", gd_op_list[op]);
+ gf_log (this->name, GF_LOG_ERROR, "Invalid op (%s)", gd_op_list[op]);
break;
}
@@ -420,17 +485,20 @@ int32_t
gd_mgmt_v3_pre_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_pre_val_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
dict_t *rsp_dict = NULL;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
frame = myframe;
args = frame->local;
@@ -444,7 +512,7 @@ gd_mgmt_v3_pre_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
}
@@ -477,7 +545,7 @@ gd_mgmt_v3_pre_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
pthread_mutex_unlock (&args->lock_dict);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "%s",
+ gf_log (this->name, GF_LOG_ERROR, "%s",
"Failed to aggregate response from "
" node/brick");
if (!rsp.op_ret)
@@ -498,6 +566,12 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_PRE_VALIDATE,
peerinfo, rsp.uuid);
+
+ if (rsp.op_errstr)
+ free (rsp.op_errstr);
+
+ free (rsp.dict.dict_val);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -505,25 +579,28 @@ out:
int32_t
gd_mgmt_v3_pre_validate_cbk (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
return glusterd_big_locked_cbk (req, iov, count, myframe,
gd_mgmt_v3_pre_validate_cbk_fn);
}
int
-gd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *op_ctx,
+gd_mgmt_v3_pre_validate_req (glusterd_op_t op, dict_t *op_ctx,
glusterd_peerinfo_t *peerinfo,
struct syncargs *args, uuid_t my_uuid,
uuid_t recv_uuid)
{
- int ret = -1;
- gd1_mgmt_v3_pre_val_req req = {{0},};
- glusterd_conf_t *conf = THIS->private;
+ int32_t ret = -1;
+ gd1_mgmt_v3_pre_val_req req = {{0},};
+ glusterd_conf_t *conf = THIS->private;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -541,7 +618,8 @@ gd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_pre_val_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -549,8 +627,8 @@ int
glusterd_mgmt_v3_pre_validate (glusterd_conf_t *conf, glusterd_op_t op,
dict_t *req_dict, char **op_errstr, int npeers)
{
- int ret = -1;
- int peer_cnt = 0;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
dict_t *rsp_dict = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
struct syncargs args = {0};
@@ -559,6 +637,11 @@ glusterd_mgmt_v3_pre_validate (glusterd_conf_t *conf, glusterd_op_t op,
xlator_t *this = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (req_dict);
+ GF_ASSERT (op_errstr);
+
peers = &conf->xaction_peers;
rsp_dict = dict_new ();
@@ -594,7 +677,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_conf_t *conf, glusterd_op_t op,
ret = glusterd_pre_validate_aggr_rsp_dict (op, req_dict,
rsp_dict);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "%s",
+ gf_log (this->name, GF_LOG_ERROR, "%s",
"Failed to aggregate response from "
" node/brick");
goto out;
@@ -613,7 +696,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_conf_t *conf, glusterd_op_t op,
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
- gd_mgmt_v3_pre_validate (op, req_dict, peerinfo, &args,
+ gd_mgmt_v3_pre_validate_req (op, req_dict, peerinfo, &args,
MY_UUID, peer_uuid);
peer_cnt++;
}
@@ -637,22 +720,22 @@ out:
int
glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict,
- glusterd_op_t op)
+ glusterd_op_t op)
{
- int ret = -1;
+ int32_t ret = -1;
dict_t *req_dict = NULL;
xlator_t *this = NULL;
- GF_ASSERT (req);
-
this = THIS;
GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (op_errstr);
+ GF_ASSERT (dict);
req_dict = dict_new ();
if (!req_dict)
goto out;
-
switch (op) {
case GD_OP_SNAP:
dict_copy (dict, req_dict);
@@ -663,25 +746,27 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict,
*req = req_dict;
ret = 0;
-
out:
return ret;
}
int32_t
gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_brick_op_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
frame = myframe;
args = frame->local;
@@ -699,7 +784,7 @@ gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
goto out;
}
@@ -718,6 +803,12 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_BRICK_OP,
peerinfo, rsp.uuid);
+
+ if (rsp.op_errstr)
+ free (rsp.op_errstr);
+
+ free (rsp.dict.dict_val);
+
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -725,25 +816,28 @@ out:
int32_t
gd_mgmt_v3_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
return glusterd_big_locked_cbk (req, iov, count, myframe,
gd_mgmt_v3_brick_op_cbk_fn);
}
int
-gd_mgmt_v3_brick_op (glusterd_op_t op, dict_t *op_ctx,
+gd_mgmt_v3_brick_op_req (glusterd_op_t op, dict_t *op_ctx,
glusterd_peerinfo_t *peerinfo,
struct syncargs *args, uuid_t my_uuid,
uuid_t recv_uuid)
{
- int ret = -1;
+ int32_t ret = -1;
gd1_mgmt_v3_brick_op_req req = {{0},};
- glusterd_conf_t *conf = THIS->private;
+ glusterd_conf_t *conf = THIS->private;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -761,16 +855,17 @@ gd_mgmt_v3_brick_op (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_brick_op_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
int
glusterd_mgmt_v3_brick_op (glusterd_conf_t *conf, glusterd_op_t op,
- dict_t *req_dict, char **op_errstr, int npeers)
+ dict_t *req_dict, char **op_errstr, int npeers)
{
- int ret = -1;
- int peer_cnt = 0;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
dict_t *rsp_dict = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
struct syncargs args = {0};
@@ -779,6 +874,11 @@ glusterd_mgmt_v3_brick_op (glusterd_conf_t *conf, glusterd_op_t op,
xlator_t *this = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (req_dict);
+ GF_ASSERT (op_errstr);
+
peers = &conf->xaction_peers;
rsp_dict = dict_new ();
@@ -824,7 +924,7 @@ glusterd_mgmt_v3_brick_op (glusterd_conf_t *conf, glusterd_op_t op,
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
- gd_mgmt_v3_brick_op (op, req_dict, peerinfo, &args,
+ gd_mgmt_v3_brick_op_req (op, req_dict, peerinfo, &args,
MY_UUID, peer_uuid);
peer_cnt++;
}
@@ -848,19 +948,22 @@ out:
int32_t
gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_commit_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
dict_t *rsp_dict = NULL;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
frame = myframe;
args = frame->local;
@@ -874,7 +977,7 @@ gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
goto out;
}
@@ -908,7 +1011,7 @@ gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
pthread_mutex_unlock (&args->lock_dict);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "%s",
+ gf_log (this->name, GF_LOG_ERROR, "%s",
"Failed to aggregate response from "
" node/brick");
if (!rsp.op_ret)
@@ -923,9 +1026,14 @@ gd_mgmt_v3_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
out:
+ if (rsp_dict)
+ dict_unref (rsp_dict);
+
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_COMMIT,
peerinfo, rsp.uuid);
+
+ free (rsp.dict.dict_val);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -933,25 +1041,28 @@ out:
int32_t
gd_mgmt_v3_commit_cbk (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
return glusterd_big_locked_cbk (req, iov, count, myframe,
gd_mgmt_v3_commit_cbk_fn);
}
int
-gd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx,
+gd_mgmt_v3_commit_req (glusterd_op_t op, dict_t *op_ctx,
glusterd_peerinfo_t *peerinfo,
struct syncargs *args, uuid_t my_uuid,
uuid_t recv_uuid)
{
- int ret = -1;
- gd1_mgmt_v3_commit_req req = {{0},};
+ int32_t ret = -1;
+ gd1_mgmt_v3_commit_req req = {{0},};
glusterd_conf_t *conf = THIS->private;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -969,17 +1080,18 @@ gd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_commit_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
int
glusterd_mgmt_v3_commit (glusterd_conf_t *conf, glusterd_op_t op,
- dict_t *op_ctx, dict_t *req_dict,
- char **op_errstr, int npeers)
+ dict_t *op_ctx, dict_t *req_dict,
+ char **op_errstr, int npeers)
{
- int ret = -1;
- int peer_cnt = 0;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
dict_t *rsp_dict = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
struct syncargs args = {0};
@@ -988,6 +1100,12 @@ glusterd_mgmt_v3_commit (glusterd_conf_t *conf, glusterd_op_t op,
xlator_t *this = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (req_dict);
+ GF_ASSERT (op_errstr);
+
peers = &conf->xaction_peers;
rsp_dict = dict_new ();
@@ -1023,7 +1141,7 @@ glusterd_mgmt_v3_commit (glusterd_conf_t *conf, glusterd_op_t op,
ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx,
rsp_dict);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "%s",
+ gf_log (this->name, GF_LOG_ERROR, "%s",
"Failed to aggregate response from "
" node/brick");
goto out;
@@ -1042,7 +1160,7 @@ glusterd_mgmt_v3_commit (glusterd_conf_t *conf, glusterd_op_t op,
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
- gd_mgmt_v3_commit (op, req_dict, peerinfo, &args,
+ gd_mgmt_v3_commit_req (op, req_dict, peerinfo, &args,
MY_UUID, peer_uuid);
peer_cnt++;
}
@@ -1066,18 +1184,21 @@ out:
int32_t
gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_post_val_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
frame = myframe;
args = frame->local;
@@ -1091,7 +1212,7 @@ gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
goto out;
}
@@ -1110,6 +1231,10 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_POST_VALIDATE,
peerinfo, rsp.uuid);
+ if (rsp.op_errstr)
+ free (rsp.op_errstr);
+
+ free (rsp.dict.dict_val);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -1117,25 +1242,28 @@ out:
int32_t
gd_mgmt_v3_post_validate_cbk (struct rpc_req *req, struct iovec *iov,
- int count, void *myframe)
+ int count, void *myframe)
{
return glusterd_big_locked_cbk (req, iov, count, myframe,
gd_mgmt_v3_post_validate_cbk_fn);
}
int
-gd_mgmt_v3_post_validate (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx,
- glusterd_peerinfo_t *peerinfo,
- struct syncargs *args, uuid_t my_uuid,
- uuid_t recv_uuid)
+gd_mgmt_v3_post_validate_req (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx,
+ glusterd_peerinfo_t *peerinfo,
+ struct syncargs *args, uuid_t my_uuid,
+ uuid_t recv_uuid)
{
- int ret = -1;
+ int32_t ret = -1;
gd1_mgmt_v3_post_val_req req = {{0},};
- glusterd_conf_t *conf = THIS->private;
+ glusterd_conf_t *conf = THIS->private;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -1154,7 +1282,8 @@ gd_mgmt_v3_post_validate (glusterd_op_t op, int32_t op_ret, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_post_val_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -1163,8 +1292,8 @@ glusterd_mgmt_v3_post_validate (glusterd_conf_t *conf, glusterd_op_t op,
int32_t op_ret, dict_t *req_dict,
char **op_errstr, int npeers)
{
- int ret = -1;
- int peer_cnt = 0;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
dict_t *rsp_dict = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
struct syncargs args = {0};
@@ -1173,6 +1302,11 @@ glusterd_mgmt_v3_post_validate (glusterd_conf_t *conf, glusterd_op_t op,
xlator_t *this = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (req_dict);
+ GF_ASSERT (op_errstr);
+
peers = &conf->xaction_peers;
rsp_dict = dict_new ();
@@ -1218,8 +1352,8 @@ glusterd_mgmt_v3_post_validate (glusterd_conf_t *conf, glusterd_op_t op,
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
- gd_mgmt_v3_post_validate (op, op_ret, req_dict, peerinfo, &args,
- MY_UUID, peer_uuid);
+ gd_mgmt_v3_post_validate_req (op, op_ret, req_dict, peerinfo,
+ &args, MY_UUID, peer_uuid);
peer_cnt++;
}
gd_synctask_barrier_wait((&args), peer_cnt);
@@ -1244,16 +1378,19 @@ int32_t
gd_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- int ret = -1;
+ int32_t ret = -1;
struct syncargs *args = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
gd1_mgmt_v3_unlock_rsp rsp = {{0},};
call_frame_t *frame = NULL;
- int op_ret = -1;
- int op_errno = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = -1;
+ xlator_t *this = NULL;
- GF_ASSERT(req);
- GF_ASSERT(myframe);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (myframe);
frame = myframe;
args = frame->local;
@@ -1267,7 +1404,7 @@ gd_mgmt_v3_unlock_cbk_fn (struct rpc_req *req, struct iovec *iov,
}
if (!iov) {
- gf_log (THIS->name, GF_LOG_ERROR, "iov is NULL");
+ gf_log (this->name, GF_LOG_ERROR, "iov is NULL");
op_errno = EINVAL;
goto out;
}
@@ -1286,6 +1423,7 @@ out:
gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_V3_UNLOCK,
peerinfo, rsp.uuid);
+ free (rsp.dict.dict_val);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@@ -1305,13 +1443,16 @@ gd_mgmt_v3_unlock (glusterd_op_t op, dict_t *op_ctx,
struct syncargs *args, uuid_t my_uuid,
uuid_t recv_uuid)
{
- int ret = -1;
+ int32_t ret = -1;
gd1_mgmt_v3_unlock_req req = {{0},};
glusterd_conf_t *conf = THIS->private;
+ xlator_t *this = NULL;
- GF_ASSERT(op_ctx);
- GF_ASSERT(peerinfo);
- GF_ASSERT(args);
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (op_ctx);
+ GF_ASSERT (peerinfo);
+ GF_ASSERT (args);
ret = dict_allocate_and_serialize (op_ctx,
&req.dict.dict_val,
@@ -1329,7 +1470,8 @@ gd_mgmt_v3_unlock (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t) xdr_gd1_mgmt_v3_unlock_req);
synclock_lock (&conf->big_lock);
out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -1339,8 +1481,8 @@ glusterd_mgmt_v3_release_peer_locks (glusterd_conf_t *conf, glusterd_op_t op,
char **op_errstr, int npeers,
gf_boolean_t is_acquired)
{
- int ret = -1;
- int peer_cnt = 0;
+ int32_t ret = -1;
+ int32_t peer_cnt = 0;
uuid_t peer_uuid = {0};
xlator_t *this = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
@@ -1348,6 +1490,11 @@ glusterd_mgmt_v3_release_peer_locks (glusterd_conf_t *conf, glusterd_op_t op,
struct list_head *peers = NULL;
this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (conf);
+ GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
+
peers = &conf->xaction_peers;
/* If the lock has not been held during this
@@ -1392,9 +1539,9 @@ int32_t
glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op,
dict_t *dict)
{
- int ret = -1;
- int op_ret = -1;
- int npeers = 0;
+ int32_t ret = -1;
+ int32_t op_ret = -1;
+ int32_t npeers = 0;
dict_t *req_dict = NULL;
dict_t *tmp_dict = NULL;
glusterd_conf_t *conf = NULL;
@@ -1405,6 +1552,8 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op,
this = THIS;
GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (dict);
conf = this->private;
GF_ASSERT (conf);
@@ -1532,11 +1681,11 @@ out:
int32_t
glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
- dict_t *dict)
+ dict_t *dict)
{
- int ret = -1;
- int op_ret = -1;
- int npeers = 0;
+ int32_t ret = -1;
+ int32_t op_ret = -1;
+ int32_t npeers = 0;
dict_t *req_dict = NULL;
dict_t *tmp_dict = NULL;
glusterd_conf_t *conf = NULL;
@@ -1549,6 +1698,8 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
this = THIS;
GF_ASSERT (this);
+ GF_ASSERT (req);
+ GF_ASSERT (dict);
conf = this->private;
GF_ASSERT (conf);