diff options
author | Dan Lambright <dlambrig@redhat.com> | 2015-04-16 05:21:16 +0100 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-05-08 10:38:08 -0700 |
commit | 680b3bf629f0fef038470baab62c6d6d8f5988ce (patch) | |
tree | 065e73785c42e9da18e2ffe6b85e518219b7a5d2 | |
parent | d4d9cfc82d7cf7797227b8b929ba193fbaf389e6 (diff) |
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 <vol> tier status
Change-Id: I1b11ca27355ceec36c488967c23531202030e205
BUG: 1213063
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-on: http://review.gluster.org/10292
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r-- | cli/src/cli-rpc-ops.c | 99 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 3 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 14 | ||||
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 55 | ||||
-rw-r--r-- | 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 2b84aa6b060..59f0c6ed9d3 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1452,15 +1452,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; @@ -1470,105 +1466,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 fbb4eaee4e5..54ad68246fb 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -6417,7 +6417,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 69d6f86019f..767b457ce77 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -2820,6 +2820,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,}; @@ -2837,6 +2839,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); @@ -2845,6 +2849,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 72e8e47837e..2387a02b00c 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 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; } diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 812a4434415..37a5737060c 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -312,6 +312,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_ { |