summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index ee4e7df61d0..4653ae798c1 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -4554,9 +4554,10 @@ gf_defrag_get_estimates (dht_conf_t *conf)
rate_lookedup = (total_processed)/elapsed;
- /* We initially sum up dirs across all local subvols.
- * The same directories will be counted for each subvol so
- * we want to ensure that they are only counted once.
+ /* We initially sum up dirs across all local subvols because we get the
+ * file count from the inodes on each subvol.
+ * The same directories will be counted for each subvol but
+ * we want that they are only counted once.
*/
tmp_count = g_totalfiles
@@ -4565,7 +4566,14 @@ gf_defrag_get_estimates (dht_conf_t *conf)
if (total_processed > g_totalfiles)
g_totalfiles = total_processed + 10000;
- time_to_complete = (tmp_count)/rate_lookedup;
+ if (rate_lookedup) {
+ time_to_complete = (tmp_count)/rate_lookedup;
+
+ } else {
+
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, 0,
+ "Unable to calculate estimated time for rebalance");
+ }
gf_log (THIS->name, GF_LOG_INFO,
"TIME: total_processed=%"PRIu64" tmp_cnt = %"PRIu64","
@@ -4618,7 +4626,9 @@ gf_defrag_status_get (dht_conf_t *conf, dict_t *dict)
&& (defrag->defrag_status == GF_DEFRAG_STATUS_STARTED)) {
time_to_complete = gf_defrag_get_estimates (conf);
- time_left = time_to_complete - elapsed;
+
+ if (time_to_complete && (time_to_complete > elapsed))
+ time_left = time_to_complete - elapsed;
gf_log (THIS->name, GF_LOG_INFO,
"TIME: Estimated total time to complete = %"PRIu64