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 --- xlators/cluster/dht/src/dht-common.c | 3 ++- xlators/cluster/dht/src/dht-rebalance.c | 14 ++++++++++++++ xlators/cluster/dht/src/tier.c | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'xlators/cluster') 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); -- cgit