summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2017-07-24 18:27:39 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-07-31 17:20:17 +0000
commit4da056a30214ad4563bdfd24ffce724b740c6b4f (patch)
tree8c2ca9cbea2d66798bacd71ce2affc89e2748977 /xlators
parent8cf3fc7b27c4f3737a1f969056dd3fa2223a9892 (diff)
cluster/dht: Fix negative rebalance estimates
The calculation of the rebalance estimates will start after the rebalance operation has been running for 10 minutes. This patch also changes the cli rebalance status code to use unsigned variables for the time calculations. > BUG: 1457985 > Signed-off-by: N Balachandran <nbalacha@redhat.com> > Reviewed-on: https://review.gluster.org/17863 > Reviewed-by: Amar Tumballi <amarts@redhat.com> > Smoke: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Atin Mukherjee <amukherj@redhat.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> (cherry picked from commit e21c915679244ddc1fae886e52badf02b4d95efc) Change-Id: Ic76f517c59ad938a407f1cf5e3b9add571690a6c BUG: 1475399 Signed-off-by: N Balachandran <nbalacha@redhat.com> Reviewed-on: https://review.gluster.org/17882 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 266dc5a99a9..f1d32a9a00c 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -18,13 +18,14 @@
#include <signal.h>
#include "events.h"
-#define GF_DISK_SECTOR_SIZE 512
+#define GF_DISK_SECTOR_SIZE 512
#define DHT_REBALANCE_PID 4242 /* Change it if required */
#define DHT_REBALANCE_BLKSIZE (1024 * 1024) /* 1 MB */
-#define MAX_MIGRATE_QUEUE_COUNT 500
-#define MIN_MIGRATE_QUEUE_COUNT 200
-#define MAX_REBAL_TYPE_SIZE 16
-#define FILE_CNT_INTERVAL 600 /* 10 mins */
+#define MAX_MIGRATE_QUEUE_COUNT 500
+#define MIN_MIGRATE_QUEUE_COUNT 200
+#define MAX_REBAL_TYPE_SIZE 16
+#define FILE_CNT_INTERVAL 600 /* 10 mins */
+#define ESTIMATE_START_INTERVAL 600 /* 10 mins */
#ifndef MAX
#define MAX(a, b) (((a) > (b))?(a):(b))
@@ -2972,7 +2973,6 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
!strcmp (df_entry->d_name, ".."))
continue;
-
if (IA_ISDIR (df_entry->d_stat.ia_type)) {
defrag->size_processed += df_entry->d_stat.ia_size;
continue;
@@ -4723,6 +4723,19 @@ gf_defrag_get_estimates_based_on_size (dht_conf_t *conf)
gettimeofday (&now, NULL);
elapsed = now.tv_sec - defrag->start_time.tv_sec;
+ /* Don't calculate the estimates for the first 10 minutes.
+ * It is unlikely to be accurate and estimates are not required
+ * if the process finishes in less than 10 mins.
+ */
+
+ if (elapsed < ESTIMATE_START_INTERVAL) {
+ gf_msg (THIS->name, GF_LOG_INFO, 0, 0,
+ "Rebalance estimates will not be available for the "
+ "first %d seconds.", ESTIMATE_START_INTERVAL);
+
+ goto out;
+ }
+
total_processed = defrag->size_processed;
/* rate at which files processed */
@@ -4734,7 +4747,6 @@ gf_defrag_get_estimates_based_on_size (dht_conf_t *conf)
time_to_complete = (tmp_count)/rate_processed;
} else {
-
gf_msg (THIS->name, GF_LOG_ERROR, 0, 0,
"Unable to calculate estimated time for rebalance");
}
@@ -4880,8 +4892,8 @@ gf_defrag_status_get (dht_conf_t *conf, dict_t *dict)
"TIME: Estimated total time to complete based on"
" count = %"PRIu64 " seconds, seconds left = %"PRIu64"",
time_to_complete, time_left);
-
*/
+
time_to_complete = gf_defrag_get_estimates_based_on_size (conf);
if (time_to_complete && (time_to_complete > elapsed))