From 530533fe44f08f30d1230c65db0054be7c6d3281 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Garg Date: Wed, 25 Nov 2015 17:38:43 +0530 Subject: bitrot: getting correct value of scrub stat's This patch is backport of: http://review.gluster.org/#/c/12776/ When user execute bitrot scrub status command then gluster is not giving correct value of Number of Scrubbed files, Number of Unsigned files, Last completed scrub time, Duration of last scrub. With this patch scrub status will give correct value for all the above fields. >> Change-Id: Ic966f76d22db5b0c889e6386a1c2219afbda1f49 >> BUG: 1285989 >> Signed-off-by: Gaurav Kumar Garg >> Signed-off-by: Kotresh HR >> Reviewed-on: http://review.gluster.org/12776 >> Tested-by: NetBSD Build System >> Tested-by: Gluster Build System >> Reviewed-by: Venky Shankar Change-Id: Ic966f76d22db5b0c889e6386a1c2219afbda1f49 BUG: 1291546 Signed-off-by: Gaurav Kumar Garg (cherry picked from commit 22827d51c232c44a8f5ac003529d907d93baf7b0) Change-Id: Icef24cce35c8d54ffdfa5282491338318e78780b Reviewed-on: http://review.gluster.org/12966 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Venky Shankar --- cli/src/cli-rpc-ops.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index b623051cad9..6dcf0f37e3f 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -10736,7 +10736,11 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) uint64_t scrub_files = 0; uint64_t unsigned_files = 0; uint64_t scrub_time = 0; - uint64_t last_scrub = 0; + uint64_t days = 0; + uint64_t hour = 0; + uint64_t minut = 0; + uint64_t second = 0; + char *last_scrub = NULL; uint64_t error_count = 0; @@ -10790,8 +10794,12 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) for (i = 1; i <= count; i++) { /* Reset the variables to prevent carryover of values */ node_name = NULL; - last_scrub = 0; + last_scrub = NULL; scrub_time = 0; + days = 0; + hour = 0; + minut = 0; + second = 0; error_count = 0; scrub_files = 0; unsigned_files = 0; @@ -10825,7 +10833,7 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) memset (key, 0, 256); snprintf (key, 256, "last-scrub-time-%d", i); - ret = dict_get_uint64 (dict, key, &last_scrub); + ret = dict_get_str (dict, key, &last_scrub); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub" " time"); @@ -10848,11 +10856,17 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) cli_out ("%s: %"PRIu64 "\n", "Number of Unsigned files", unsigned_files); - cli_out ("%s: %"PRIu64 "\n", "Last completed scrub time", - scrub_time); - - cli_out ("%s: %"PRIu64 "\n", "Duration of last scrub", - last_scrub); + cli_out ("%s: %s\n", "Last completed scrub time", + (*last_scrub) ? last_scrub : "Scrubber pending to " + "complete."); + + /* Printing last scrub duration time in human readable form*/ + days = scrub_time/86400; + hour = (scrub_time%86400)/3600; + minut = (scrub_time%86400%3600)/60; + second = (scrub_time%86400%3600%60); + cli_out ("%s: %"PRIu64 ":%"PRIu64 ":%"PRIu64 ":%"PRIu64 "\n", + "Duration of last scrub", days, hour, minut, second); cli_out ("%s: %"PRIu64 "\n", "Error count", error_count); -- cgit