summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
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/glusterd/src/glusterd-utils.c
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/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c82
1 files changed, 50 insertions, 32 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 5314821c..f778ec76 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;