summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-12-12 15:11:35 +0530
committerAnand Avati <avati@redhat.com>2013-02-03 11:56:18 -0800
commitb070c7be6f687e197260a764abe4357d419b205c (patch)
tree185be76036730adf0122a30ba79a974d7595599e /xlators/mgmt
parent2d0da44826d4b4652169604785ec63cce805bddd (diff)
glusterd: Made volume-status use synctask framework
Change-Id: Id4062799104e5831467ced65a43bfe377b6163f4 BUG: 852147 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/4297 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c17
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c82
5 files changed, 65 insertions, 44 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 1979f7e2aa4..0993d276370 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -2976,12 +2976,9 @@ glusterd_handle_status_volume (rpcsvc_request_t *req)
}
- ret = glusterd_op_begin (req, GD_OP_STATUS_VOLUME, dict,
- err_str, sizeof (err_str));
+ ret = glusterd_op_begin_synctask (req, GD_OP_STATUS_VOLUME, dict);
out:
- glusterd_friend_sm ();
- glusterd_op_sm ();
if (ret) {
if (err_str[0] == '\0')
@@ -3261,6 +3258,7 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
case GD_OP_START_VOLUME:
case GD_OP_ADD_BRICK:
case GD_OP_REMOVE_BRICK:
+ case GD_OP_STATUS_VOLUME:
break;
default:
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 8c632ffbf01..fcccf480598 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1932,11 +1932,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
if (ret)
goto out;
- if (!rsp_dict) {
- //this should happen only on source
+ if (is_origin_glusterd ()) {
ret = 0;
- rsp_dict = glusterd_op_get_ctx ();
-
if ((cmd & GF_CLI_STATUS_ALL)) {
ret = glusterd_get_all_volnames (rsp_dict);
if (ret)
@@ -2868,7 +2865,7 @@ out:
* hostnames etc.
*/
void
-glusterd_op_modify_op_ctx (glusterd_op_t op)
+glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
{
int ret = -1;
dict_t *op_ctx = NULL;
@@ -2881,7 +2878,11 @@ glusterd_op_modify_op_ctx (glusterd_op_t op)
this = THIS;
GF_ASSERT (this);
- op_ctx = glusterd_op_get_ctx();
+ if (ctx)
+ op_ctx = ctx;
+ else
+ op_ctx = glusterd_op_get_ctx();
+
if (!op_ctx) {
gf_log (this->name, GF_LOG_CRITICAL,
"Operation context is not present.");
@@ -3129,7 +3130,7 @@ out:
ret = glusterd_op_start_rb_timer (op_dict);
} else {
- glusterd_op_modify_op_ctx (op);
+ glusterd_op_modify_op_ctx (op, NULL);
ret = glusterd_op_sm_inject_all_acc ();
}
goto err;
@@ -3299,7 +3300,7 @@ out:
if (ret)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_RCVD_RJT, NULL);
else if (!opinfo.pending_count) {
- glusterd_op_modify_op_ctx (op);
+ glusterd_op_modify_op_ctx (op, NULL);
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, NULL);
}
/*else do nothing*/
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 7e64081ceb0..21493bbd9da 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -249,6 +249,8 @@ glusterd_handle_brick_rsp (void *pending_entry, glusterd_op_t op,
dict_t*
glusterd_op_init_commit_rsp_dict (glusterd_op_t op);
+void
+glusterd_op_modify_op_ctx (glusterd_op_t op, void *op_ctx);
int32_t
glusterd_op_init_ctx (glusterd_op_t op);
int32_t
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index a8f58e0255d..835cc4ea827 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -832,6 +832,8 @@ commit_done:
gf_asprintf (&op_errstr, OPERRSTR_COMMIT_FAIL,
hostname);
goto out;
+ } else {
+ glusterd_op_modify_op_ctx (op, op_ctx);
}
ret = 0;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 5314821ca8d..f778ec76318 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -6599,28 +6599,57 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict)
{
int ret = 0;
glusterd_status_rsp_conv_t rsp_ctx = {0};
+ int32_t cmd = GF_CLI_STATUS_NONE;
int32_t node_count = 0;
- int32_t rsp_node_count = 0;
- int32_t brick_index_max = -1;
- int32_t rsp_brick_index_max = -1;
int32_t other_count = 0;
+ int32_t brick_index_max = -1;
+ int32_t rsp_node_count = 0;
int32_t rsp_other_count = 0;
+ int vol_count = -1;
+ int i = 0;
dict_t *ctx_dict = NULL;
- glusterd_op_t op = GD_OP_NONE;
+ char key[PATH_MAX] = {0,};
+ char *volname = NULL;
GF_ASSERT (rsp_dict);
- ret = dict_get_int32 (rsp_dict, "count", &rsp_node_count);
- if (ret) {
- ret = 0; //no bricks in the rsp
+ if (aggr) {
+ ctx_dict = aggr;
+
+ } else {
+ ctx_dict = glusterd_op_get_ctx (GD_OP_STATUS_VOLUME);
+
+ }
+
+ ret = dict_get_int32 (ctx_dict, "cmd", &cmd);
+ if (ret)
goto out;
+
+ if (cmd & GF_CLI_STATUS_ALL && is_origin_glusterd ()) {
+ ret = dict_get_int32 (rsp_dict, "vol_count", &vol_count);
+ if (ret == 0) {
+ ret = dict_set_int32 (ctx_dict, "vol_count",
+ vol_count);
+ if (ret)
+ goto out;
+
+ for (i = 0; i < vol_count; i++) {
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "vol%d", i);
+ ret = dict_get_str (rsp_dict, key, &volname);
+ if (ret)
+ goto out;
+
+ ret = dict_set_str (ctx_dict, key, volname);
+ if (ret)
+ goto out;
+ }
+ }
}
- ret = dict_get_int32 (rsp_dict, "brick-index-max",
- &rsp_brick_index_max);
+ ret = dict_get_int32 (rsp_dict, "count", &rsp_node_count);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
- "Failed to get brick index max from rsp_dict");
+ ret = 0; //no bricks in the rsp
goto out;
}
@@ -6631,30 +6660,19 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict)
goto out;
}
- op = glusterd_op_get_op ();
- GF_ASSERT (GD_OP_STATUS_VOLUME == op);
- if (aggr) {
- ctx_dict = aggr;
-
- } else {
- ctx_dict = glusterd_op_get_ctx (op);
-
- }
-
ret = dict_get_int32 (ctx_dict, "count", &node_count);
- ret = dict_get_int32 (ctx_dict, "brick-index-max", &brick_index_max);
- if (ret) {
- //This happens when flag GF_CLI_STATUS_BRICK is on
- brick_index_max = rsp_brick_index_max;
- ret = dict_set_int32 (ctx_dict, "brick-index-max",
- rsp_brick_index_max);
- if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
- "Failed to update brick index max");
+ ret = dict_get_int32 (ctx_dict, "other-count", &other_count);
+ if (!dict_get (ctx_dict, "brick-index-max")) {
+ ret = dict_get_int32 (rsp_dict, "brick-index-max", &brick_index_max);
+ if (ret)
goto out;
- }
+ ret = dict_set_int32 (ctx_dict, "brick-index-max", brick_index_max);
+ if (ret)
+ goto out;
+
+ } else {
+ ret = dict_get_int32 (ctx_dict, "brick-index-max", &brick_index_max);
}
- ret = dict_get_int32 (ctx_dict, "other-count", &other_count);
rsp_ctx.count = node_count;
rsp_ctx.brick_index_max = brick_index_max;