21ab4e
From 7adb9671b97ac302cfc3f02effb8c71628958e14 Mon Sep 17 00:00:00 2001
21ab4e
From: N Balachandran <nbalacha@redhat.com>
21ab4e
Date: Mon, 19 Jun 2017 11:50:28 +0530
21ab4e
Subject: [PATCH 526/529] cluster/dht: Additional checks for rebalance
21ab4e
 estimates
21ab4e
21ab4e
The rebalance estimates calculation was not handling
21ab4e
calculations correctly when no files had been processed,
21ab4e
i.e., when rate_lookedup was 0.
21ab4e
21ab4e
Now, the estimated time is set to 0 in such scenarios as
21ab4e
there is no way for rebalance to figure out how long the
21ab4e
process will take to complete without knowing the rate at
21ab4e
which the files are being processed.
21ab4e
21ab4e
> BUG: 1457985
21ab4e
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17564
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
21ab4e
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
21ab4e
21ab4e
Change-Id: I7b6378e297e1ba139852bcb2239adf2477336b5b
21ab4e
BUG: 1454602
21ab4e
Signed-off-by: N Balachandran <nbalacha@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/109749
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/cluster/dht/src/dht-rebalance.c | 20 +++++++++++++++-----
21ab4e
 1 file changed, 15 insertions(+), 5 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
21ab4e
index a23a92a..87e3dc5 100644
21ab4e
--- a/xlators/cluster/dht/src/dht-rebalance.c
21ab4e
+++ b/xlators/cluster/dht/src/dht-rebalance.c
21ab4e
@@ -4560,9 +4560,10 @@ gf_defrag_get_estimates (dht_conf_t *conf)
21ab4e
         rate_lookedup = (total_processed)/elapsed;
21ab4e
 
21ab4e
 
21ab4e
-        /* We initially sum up dirs across all local subvols.
21ab4e
-         * The same directories will be counted for each subvol so
21ab4e
-         * we want to ensure that they are only counted once.
21ab4e
+        /* We initially sum up dirs across all local subvols because we get the
21ab4e
+         * file count from the inodes on each subvol.
21ab4e
+         * The same directories will be counted for each subvol but
21ab4e
+         * we want that they are only counted once.
21ab4e
          */
21ab4e
 
21ab4e
         tmp_count = g_totalfiles
21ab4e
@@ -4571,7 +4572,14 @@ gf_defrag_get_estimates (dht_conf_t *conf)
21ab4e
         if (total_processed > g_totalfiles)
21ab4e
                 g_totalfiles = total_processed + 10000;
21ab4e
 
21ab4e
-        time_to_complete = (tmp_count)/rate_lookedup;
21ab4e
+        if (rate_lookedup) {
21ab4e
+                time_to_complete = (tmp_count)/rate_lookedup;
21ab4e
+
21ab4e
+        } else {
21ab4e
+
21ab4e
+                gf_msg (THIS->name, GF_LOG_ERROR, 0, 0,
21ab4e
+                        "Unable to calculate estimated time for rebalance");
21ab4e
+        }
21ab4e
 
21ab4e
         gf_log (THIS->name, GF_LOG_INFO,
21ab4e
                 "TIME: total_processed=%"PRIu64" tmp_cnt = %"PRIu64","
21ab4e
@@ -4624,7 +4632,9 @@ gf_defrag_status_get (dht_conf_t *conf, dict_t *dict)
21ab4e
                 && (defrag->defrag_status == GF_DEFRAG_STATUS_STARTED)) {
21ab4e
 
21ab4e
                 time_to_complete = gf_defrag_get_estimates (conf);
21ab4e
-                time_left = time_to_complete - elapsed;
21ab4e
+
21ab4e
+                if (time_to_complete && (time_to_complete > elapsed))
21ab4e
+                        time_left = time_to_complete - elapsed;
21ab4e
 
21ab4e
                 gf_log (THIS->name, GF_LOG_INFO,
21ab4e
                         "TIME: Estimated total time to complete = %"PRIu64
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e