From 680b3bf629f0fef038470baab62c6d6d8f5988ce Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Thu, 16 Apr 2015 05:21:16 +0100 Subject: glusterd: add counter support for tiered volumes This fix adds support to view the number of promoted or demoted files from the cli. The mechanism is isolmorphic to checking the status of volumes being rebalanced. gluster volume rebalance tier status Change-Id: I1b11ca27355ceec36c488967c23531202030e205 BUG: 1213063 Signed-off-by: Mohammed Rafi KC Signed-off-by: Dan Lambright Reviewed-on: http://review.gluster.org/10292 Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-utils.c | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (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 431db7d8785..45564bc0004 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6553,6 +6553,8 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, uint64_t skipped = 0; xlator_t *this = NULL; double run_time = 0; + uint64_t promoted = 0; + uint64_t demoted = 0; this = THIS; @@ -6586,6 +6588,16 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, gf_log (this->name, GF_LOG_TRACE, "failed to get skipped count"); + ret = dict_get_uint64 (rsp_dict, "promoted", &promoted); + if (ret) + gf_log (this->name, GF_LOG_TRACE, + "failed to get promoted count"); + + ret = dict_get_uint64 (rsp_dict, "demoted", &demoted); + if (ret) + gf_log (this->name, GF_LOG_TRACE, + "failed to get demoted count"); + ret = dict_get_double (rsp_dict, "run-time", &run_time); if (ret) gf_log (this->name, GF_LOG_TRACE, @@ -6605,6 +6617,10 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo, volinfo->rebal.skipped_files = skipped; if (run_time) volinfo->rebal.rebalance_time = run_time; + if (promoted) + volinfo->tier_info.promoted = promoted; + if (demoted) + volinfo->tier_info.demoted = demoted; return ret; } @@ -7678,6 +7694,31 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } + memset (key, 0, 256); + snprintf (key, 256, "demoted-%d", index); + ret = dict_get_uint64 (rsp_dict, key, &value); + if (!ret) { + memset (key, 0, 256); + snprintf (key, 256, "demoted-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set demoted count"); + } + } + memset (key, 0, 256); + snprintf (key, 256, "promoted-%d", index); + ret = dict_get_uint64 (rsp_dict, key, &value); + if (!ret) { + memset (key, 0, 256); + snprintf (key, 256, "promoted-%d", current_index); + ret = dict_set_uint64 (ctx_dict, key, value); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set promoted count"); + } + } + ret = 0; out: @@ -8282,6 +8323,20 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, gf_log (THIS->name, GF_LOG_ERROR, "failed to set run-time"); + memset (key, 0 , 256); + snprintf (key, 256, "promoted-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.promoted); + if (ret) + gf_log (THIS->name, GF_LOG_ERROR, + "failed to set lookedup file count"); + + memset (key, 0 , 256); + snprintf (key, 256, "demoted-%d", i); + ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.demoted); + if (ret) + gf_log (THIS->name, GF_LOG_ERROR, + "failed to set lookedup file count"); + out: return ret; } -- cgit