From 4e2bc057ee5afb412d9056dc71a6bb959fb11df6 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 back port of http://review.gluster.org/10292 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 Change-Id: I543e886f17132b544274c83fdecca5a8da9d092a BUG: 1221477 Signed-off-by: Mohammed Rafi KC Signed-off-by: Dan Lambright Reviewed-on: http://review.gluster.org/10775 Tested-by: Gluster Build System Reviewed-by: Atin Mukherjee --- cli/src/cli-rpc-ops.c | 99 +++++++----------------------- xlators/cluster/dht/src/dht-common.c | 3 +- xlators/cluster/dht/src/dht-rebalance.c | 14 +++++ xlators/cluster/dht/src/tier.c | 6 ++ xlators/mgmt/glusterd/src/glusterd-utils.c | 55 +++++++++++++++++ xlators/mgmt/glusterd/src/glusterd.h | 2 + 6 files changed, 100 insertions(+), 79 deletions(-) diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index a6315e28e43..f3ed8adfdc2 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1602,15 +1602,11 @@ gf_cli_print_tier_status (dict_t *dict, enum gf_task_types task_type) int ret = -1; int count = 0; int i = 1; + uint64_t promoted = 0; + uint64_t demoted = 0; char key[256] = {0,}; - gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; - uint64_t files = 0; - uint64_t size = 0; - uint64_t lookup = 0; char *node_name = NULL; - uint64_t failures = 0; - uint64_t skipped = 0; - double elapsed = 0; + gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; char *status_str = NULL; char *size_str = NULL; @@ -1620,105 +1616,52 @@ gf_cli_print_tier_status (dict_t *dict, enum gf_task_types task_type) goto out; } + cli_out ("%-20s %-20s %-20s %-20s", "Node", "Promoted files", + "Demoted files", "Status"); + cli_out ("%-20s %-20s %-20s %-20s", "---------", "---------", + "---------", "---------"); - cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s", "Node", - "Rebalanced-files", "size", "scanned", "failures", "skipped", - "status", "run time in secs"); - cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s", "---------", - "-----------", "-----------", "-----------", "-----------", - "-----------", "------------", "--------------"); for (i = 1; i <= count; i++) { /* Reset the variables to prevent carryover of values */ node_name = NULL; - files = 0; - size = 0; - lookup = 0; - skipped = 0; - status_str = NULL; - elapsed = 0; + promoted = 0; + demoted = 0; - /* Check if status is NOT_STARTED, and continue early */ memset (key, 0, 256); - snprintf (key, 256, "status-%d", i); - ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); - if (ret) { - gf_log ("cli", GF_LOG_TRACE, "failed to get status"); - goto out; - } - if (GF_DEFRAG_STATUS_NOT_STARTED == status_rcd) - continue; - - snprintf (key, 256, "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get node-name"); memset (key, 0, 256); - snprintf (key, 256, "files-%d", i); - ret = dict_get_uint64 (dict, key, &files); - if (ret) - gf_log ("cli", GF_LOG_TRACE, - "failed to get file count"); - - memset (key, 0, 256); - snprintf (key, 256, "size-%d", i); - ret = dict_get_uint64 (dict, key, &size); - if (ret) - gf_log ("cli", GF_LOG_TRACE, - "failed to get size of xfer"); - - memset (key, 0, 256); - snprintf (key, 256, "lookups-%d", i); - ret = dict_get_uint64 (dict, key, &lookup); + snprintf (key, 256, "promoted-%d", i); + ret = dict_get_uint64 (dict, key, &promoted); if (ret) gf_log ("cli", GF_LOG_TRACE, - "failed to get lookedup file count"); + "failed to get promoted count"); memset (key, 0, 256); - snprintf (key, 256, "failures-%d", i); - ret = dict_get_uint64 (dict, key, &failures); + snprintf (key, 256, "demoted-%d", i); + ret = dict_get_uint64 (dict, key, &demoted); if (ret) gf_log ("cli", GF_LOG_TRACE, - "failed to get failures count"); + "failed to get demoted count"); memset (key, 0, 256); - snprintf (key, 256, "skipped-%d", i); - ret = dict_get_uint64 (dict, key, &skipped); + snprintf (key, 256, "status-%d", i); + ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); if (ret) gf_log ("cli", GF_LOG_TRACE, - "failed to get skipped count"); - - /* For remove-brick include skipped count into failure count*/ - if (task_type != GF_TASK_TYPE_REBALANCE) { - failures += skipped; - skipped = 0; - } - - memset (key, 0, 256); - snprintf (key, 256, "run-time-%d", i); - ret = dict_get_double (dict, key, &elapsed); - if (ret) - gf_log ("cli", GF_LOG_TRACE, "failed to get run-time"); + "failed to get status"); /* Check for array bound */ if (status_rcd >= GF_DEFRAG_STATUS_MAX) status_rcd = GF_DEFRAG_STATUS_MAX; status_str = cli_vol_task_status_str[status_rcd]; - size_str = gf_uint64_2human_readable(size); - if (size_str) { - cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64 " %13" - PRIu64" %13"PRIu64 " %20s %18.2f", node_name, - files, size_str, lookup, failures, skipped, - status_str, elapsed); - } else { - cli_out ("%40s %16"PRIu64 " %13"PRIu64 " %13"PRIu64 - " %13"PRIu64" %13"PRIu64 " %20s %18.2f", - node_name, files, size, lookup, failures, - skipped, status_str, elapsed); - } - GF_FREE(size_str); + cli_out ("%-20s %-20"PRIu64" %-20"PRIu64" %-20s", + node_name, promoted, demoted, status_str); + } out: return ret; diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 20ad4f2bd72..8309b317017 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -6482,7 +6482,8 @@ dht_notify (xlator_t *this, int event, void *data, ...) { if (defrag->is_exiting) goto unlock; - if (cmd == GF_DEFRAG_CMD_STATUS) + if ((cmd == GF_DEFRAG_CMD_STATUS) || + (cmd == GF_DEFRAG_CMD_STATUS_TIER)) gf_defrag_status_get (defrag, output); else if (cmd == GF_DEFRAG_CMD_START_DETACH_TIER) gf_defrag_start_detach_tier(defrag); diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 9c42af934e4..fcb005ecc3d 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -2911,6 +2911,8 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict) uint64_t lookup = 0; uint64_t failures = 0; uint64_t skipped = 0; + uint64_t promoted = 0; + uint64_t demoted = 0; char *status = ""; double elapsed = 0; struct timeval end = {0,}; @@ -2928,6 +2930,8 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict) lookup = defrag->num_files_lookedup; failures = defrag->total_failures; skipped = defrag->skipped; + promoted = defrag->total_files_promoted; + demoted = defrag->total_files_demoted; gettimeofday (&end, NULL); @@ -2936,6 +2940,16 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict) if (!dict) goto log; + ret = dict_set_uint64 (dict, "promoted", promoted); + if (ret) + gf_log (THIS->name, GF_LOG_WARNING, + "failed to set promoted count"); + + ret = dict_set_uint64 (dict, "demoted", demoted); + if (ret) + gf_log (THIS->name, GF_LOG_WARNING, + "failed to set demoted count"); + ret = dict_set_uint64 (dict, "files", files); if (ret) gf_log (THIS->name, GF_LOG_WARNING, diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 2526604eaba..bf481601bd8 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -365,6 +365,12 @@ tier_migrate_using_query_file (void *_args) per_link_status = -1; goto error; } + + if (query_cbk_args->is_promotion) + defrag->total_files_promoted++; + else + defrag->total_files_demoted++; + error: loc_wipe(&loc); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 04e5707058a..9445de77127 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6707,6 +6707,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; @@ -6740,6 +6742,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, @@ -6759,6 +6771,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; } @@ -7863,6 +7879,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: @@ -8467,6 +8508,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; } diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 5341192e84a..384b6f4186e 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -314,6 +314,8 @@ typedef struct tier_info_ { int hot_type; int hot_brick_count; int hot_replica_count; + int promoted; + int demoted; } gd_tier_info_t; struct glusterd_volinfo_ { -- cgit