From b070c7be6f687e197260a764abe4357d419b205c Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Wed, 12 Dec 2012 15:11:35 +0530 Subject: glusterd: Made volume-status use synctask framework Change-Id: Id4062799104e5831467ced65a43bfe377b6163f4 BUG: 852147 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.org/4297 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-utils.c | 82 ++++++++++++++++++------------ 1 file changed, 50 insertions(+), 32 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 5314821ca..f778ec763 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; -- cgit