From 99e5f3af513446f382e80e3086398532ca914692 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Fri, 28 Oct 2011 16:46:56 +0530 Subject: glusterd: Fixed volume profile's "are all bricks down?" algo. "count" key is not set if no brick in the volume (located across peers) is running. Sending "count" even when zero bricks are running from originator glusterd to client, simplifies "are all bricks down?" algo. Change-Id: I3a8db48c4c61cd31ba96031638a3c3d26efd2887 BUG: 3553 Reviewed-on: http://review.gluster.com/641 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 12 ++++++++++++ xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 7cf5929d87c..9b91637ddad 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3109,6 +3109,12 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov, ret = dict_get_int32 (dict, "count", &brick_count); if (ret) goto out; + + if (!brick_count) { + cli_out ("All bricks of volume %s are down.", volname); + goto out; + } + while (i <= brick_count) { snprintf (key, sizeof (key), "%d-cumulative", i); ret = dict_get_int32 (dict, key, &interval); @@ -3241,6 +3247,12 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov, ret = dict_get_int32 (dict, "count", &brick_count); if (ret) goto out; + + if (!brick_count) { + cli_out ("All bricks of volume %s are down."); + goto out; + } + snprintf (key, sizeof (key), "%d-top-op", 1); ret = dict_get_int32 (dict, key, (int32_t*)&top_op); if (ret) diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index dad6d513c74..2d8c6e75881 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -58,6 +58,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, char *free_ptr = NULL; glusterd_conf_t *conf = NULL; + GF_ASSERT (op_ctx); GF_ASSERT (THIS); conf = THIS->private; @@ -331,7 +332,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, } case GD_OP_PROFILE_VOLUME: { - gf1_cli_stats_volume_rsp rsp = {0,}; + gf1_cli_stats_volume_rsp rsp = {0,}; + int32_t count = 0; rsp.op_ret = op_ret; rsp.op_errno = op_errno; if (op_errstr) @@ -339,6 +341,12 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; ctx = op_ctx; + if (dict_get_int32 (ctx, "count", &count)) { + ret = dict_set_int32 (ctx, "count", 0); + if (ret) + gf_log (THIS->name, GF_LOG_WARNING, "Failed " + "to set brick count."); + } dict_allocate_and_serialize (ctx, &rsp.stats_info.stats_info_val, (size_t*)&rsp.stats_info.stats_info_len); -- cgit