|
|
21ab4e |
From a6edca5fda5d1919bf39d6f2d5a349e86c0e792b Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
Date: Thu, 1 Jun 2017 22:13:41 +0530
|
|
|
21ab4e |
Subject: [PATCH 506/509] cluster/dht: Include dirs in rebalance estimates
|
|
|
21ab4e |
|
|
|
21ab4e |
Empty directories were not being considered while
|
|
|
21ab4e |
calculating rebalance estimates leading to negative
|
|
|
21ab4e |
time-left values being displayed as part of the
|
|
|
21ab4e |
rebalance status.
|
|
|
21ab4e |
|
|
|
21ab4e |
> BUG: 1457985
|
|
|
21ab4e |
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/17448
|
|
|
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: I48d41d702e72db30af10e6b87b628baa605afa98
|
|
|
21ab4e |
BUG: 1454602
|
|
|
21ab4e |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Ie04f887b19b3bb8fed63aaa3153a63109fe51631
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/108885
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
xlators/cluster/dht/src/dht-common.c | 6 +-
|
|
|
21ab4e |
xlators/cluster/dht/src/dht-common.h | 5 +-
|
|
|
21ab4e |
xlators/cluster/dht/src/dht-rebalance.c | 103 ++++++++++++++++++++++++--------
|
|
|
21ab4e |
3 files changed, 83 insertions(+), 31 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
index 052ac7f..7465275 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
@@ -9184,7 +9184,7 @@ dht_notify (xlator_t *this, int event, void *data, ...)
|
|
|
21ab4e |
DHT_MSG_CHILD_DOWN,
|
|
|
21ab4e |
"Received CHILD_DOWN. Exiting");
|
|
|
21ab4e |
if (conf->defrag) {
|
|
|
21ab4e |
- gf_defrag_stop (conf->defrag,
|
|
|
21ab4e |
+ gf_defrag_stop (conf,
|
|
|
21ab4e |
GF_DEFRAG_STATUS_FAILED, NULL);
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
kill (getpid(), SIGTERM);
|
|
|
21ab4e |
@@ -9264,12 +9264,12 @@ dht_notify (xlator_t *this, int event, void *data, ...)
|
|
|
21ab4e |
goto unlock;
|
|
|
21ab4e |
if ((cmd == GF_DEFRAG_CMD_STATUS) ||
|
|
|
21ab4e |
(cmd == GF_DEFRAG_CMD_STATUS_TIER))
|
|
|
21ab4e |
- gf_defrag_status_get (defrag, output);
|
|
|
21ab4e |
+ gf_defrag_status_get (conf, output);
|
|
|
21ab4e |
else if (cmd == GF_DEFRAG_CMD_START_DETACH_TIER)
|
|
|
21ab4e |
gf_defrag_start_detach_tier(defrag);
|
|
|
21ab4e |
else if (cmd == GF_DEFRAG_CMD_STOP ||
|
|
|
21ab4e |
cmd == GF_DEFRAG_CMD_STOP_DETACH_TIER)
|
|
|
21ab4e |
- gf_defrag_stop (defrag,
|
|
|
21ab4e |
+ gf_defrag_stop (conf,
|
|
|
21ab4e |
GF_DEFRAG_STATUS_STOPPED, output);
|
|
|
21ab4e |
else if (cmd == GF_DEFRAG_CMD_PAUSE_TIER)
|
|
|
21ab4e |
ret = gf_defrag_pause_tier (this, defrag);
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
|
|
|
21ab4e |
index eb1f2bd..81471f7 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/dht-common.h
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/dht-common.h
|
|
|
21ab4e |
@@ -424,6 +424,7 @@ struct gf_defrag_info_ {
|
|
|
21ab4e |
uint64_t num_files_lookedup;
|
|
|
21ab4e |
uint64_t total_failures;
|
|
|
21ab4e |
uint64_t skipped;
|
|
|
21ab4e |
+ uint64_t num_dirs_processed;
|
|
|
21ab4e |
gf_lock_t lock;
|
|
|
21ab4e |
int cmd;
|
|
|
21ab4e |
pthread_t th;
|
|
|
21ab4e |
@@ -1070,7 +1071,7 @@ int dht_newfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
21ab4e |
struct iatt *postparent, dict_t *xdata);
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
-gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict);
|
|
|
21ab4e |
+gf_defrag_status_get (dht_conf_t *conf, dict_t *dict);
|
|
|
21ab4e |
|
|
|
21ab4e |
void
|
|
|
21ab4e |
gf_defrag_set_pause_state (gf_tier_conf_t *tier_conf, tier_pause_state_t state);
|
|
|
21ab4e |
@@ -1091,7 +1092,7 @@ int
|
|
|
21ab4e |
gf_defrag_start_detach_tier (gf_defrag_info_t *defrag);
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
-gf_defrag_stop (gf_defrag_info_t *defrag, gf_defrag_status_t status,
|
|
|
21ab4e |
+gf_defrag_stop (dht_conf_t *conf, gf_defrag_status_t status,
|
|
|
21ab4e |
dict_t *output);
|
|
|
21ab4e |
|
|
|
21ab4e |
void*
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
index 1ee76fc..a23a92a 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
@@ -3324,6 +3324,11 @@ out:
|
|
|
21ab4e |
ret = 2;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ /* It does not matter if it errored out - this number is
|
|
|
21ab4e |
+ * used to calculate rebalance estimated time to complete.
|
|
|
21ab4e |
+ * No locking required as dirs are processed by a single thread.
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ defrag->num_dirs_processed++;
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
int
|
|
|
21ab4e |
@@ -4437,7 +4442,7 @@ out:
|
|
|
21ab4e |
LOCK (&defrag->lock);
|
|
|
21ab4e |
{
|
|
|
21ab4e |
status = dict_new ();
|
|
|
21ab4e |
- gf_defrag_status_get (defrag, status);
|
|
|
21ab4e |
+ gf_defrag_status_get (conf, status);
|
|
|
21ab4e |
if (ctx && ctx->notify)
|
|
|
21ab4e |
ctx->notify (GF_EN_DEFRAG_STATUS, status);
|
|
|
21ab4e |
if (status)
|
|
|
21ab4e |
@@ -4519,8 +4524,66 @@ out:
|
|
|
21ab4e |
return NULL;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+uint64_t
|
|
|
21ab4e |
+gf_defrag_get_estimates (dht_conf_t *conf)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ gf_defrag_info_t *defrag = NULL;
|
|
|
21ab4e |
+ double rate_lookedup = 0;
|
|
|
21ab4e |
+ uint64_t dirs_processed = 0;
|
|
|
21ab4e |
+ uint64_t total_processed = 0;
|
|
|
21ab4e |
+ uint64_t tmp_count = 0;
|
|
|
21ab4e |
+ uint64_t time_to_complete = 0;
|
|
|
21ab4e |
+ struct timeval end = {0,};
|
|
|
21ab4e |
+ double elapsed = 0;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ defrag = conf->defrag;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!g_totalfiles)
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gettimeofday (&end, NULL);
|
|
|
21ab4e |
+ elapsed = end.tv_sec - defrag->start_time.tv_sec;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* I tried locking before accessing num_files_lookedup and
|
|
|
21ab4e |
+ * num_dirs_processed but the status function
|
|
|
21ab4e |
+ * never seemed to get the lock, causing the status cli to
|
|
|
21ab4e |
+ * hang.
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ dirs_processed = defrag->num_dirs_processed;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ total_processed = defrag->num_files_lookedup
|
|
|
21ab4e |
+ + dirs_processed;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* rate at which files looked up */
|
|
|
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 |
+ */
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ tmp_count = g_totalfiles
|
|
|
21ab4e |
+ - (dirs_processed * (conf->local_subvols_cnt - 1));
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (total_processed > g_totalfiles)
|
|
|
21ab4e |
+ g_totalfiles = total_processed + 10000;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ time_to_complete = (tmp_count)/rate_lookedup;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gf_log (THIS->name, GF_LOG_INFO,
|
|
|
21ab4e |
+ "TIME: total_processed=%"PRIu64" tmp_cnt = %"PRIu64","
|
|
|
21ab4e |
+ "rate_lookedup=%f", total_processed, tmp_count,
|
|
|
21ab4e |
+ rate_lookedup);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return time_to_complete;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+
|
|
|
21ab4e |
int
|
|
|
21ab4e |
-gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict)
|
|
|
21ab4e |
+gf_defrag_status_get (dht_conf_t *conf, dict_t *dict)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
int ret = 0;
|
|
|
21ab4e |
uint64_t files = 0;
|
|
|
21ab4e |
@@ -4532,11 +4595,10 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict)
|
|
|
21ab4e |
uint64_t demoted = 0;
|
|
|
21ab4e |
char *status = "";
|
|
|
21ab4e |
double elapsed = 0;
|
|
|
21ab4e |
- uint64_t time_left = 0;
|
|
|
21ab4e |
- uint64_t time_to_complete = 0;
|
|
|
21ab4e |
- double rate_lookedup = 0;
|
|
|
21ab4e |
struct timeval end = {0,};
|
|
|
21ab4e |
-
|
|
|
21ab4e |
+ uint64_t time_to_complete = 0;
|
|
|
21ab4e |
+ uint64_t time_left = 0;
|
|
|
21ab4e |
+ gf_defrag_info_t *defrag = conf->defrag;
|
|
|
21ab4e |
|
|
|
21ab4e |
if (!defrag)
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
@@ -4557,34 +4619,20 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict)
|
|
|
21ab4e |
|
|
|
21ab4e |
elapsed = end.tv_sec - defrag->start_time.tv_sec;
|
|
|
21ab4e |
|
|
|
21ab4e |
-/*START */
|
|
|
21ab4e |
-
|
|
|
21ab4e |
-/* rate at which files looked up */
|
|
|
21ab4e |
-
|
|
|
21ab4e |
|
|
|
21ab4e |
if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER)
|
|
|
21ab4e |
- && (defrag->defrag_status == GF_DEFRAG_STATUS_STARTED)
|
|
|
21ab4e |
- && g_totalfiles) {
|
|
|
21ab4e |
+ && (defrag->defrag_status == GF_DEFRAG_STATUS_STARTED)) {
|
|
|
21ab4e |
|
|
|
21ab4e |
- rate_lookedup = (defrag->num_files_lookedup)/elapsed;
|
|
|
21ab4e |
- if (defrag->num_files_lookedup > g_totalfiles)
|
|
|
21ab4e |
- g_totalfiles = defrag->num_files_lookedup + 10000;
|
|
|
21ab4e |
- time_to_complete = (g_totalfiles)/rate_lookedup;
|
|
|
21ab4e |
+ time_to_complete = gf_defrag_get_estimates (conf);
|
|
|
21ab4e |
time_left = time_to_complete - elapsed;
|
|
|
21ab4e |
|
|
|
21ab4e |
gf_log (THIS->name, GF_LOG_INFO,
|
|
|
21ab4e |
- "TIME: num_files_lookedup=%"PRIu64",elapsed time = %f,"
|
|
|
21ab4e |
- "rate_lookedup=%f", defrag->num_files_lookedup, elapsed,
|
|
|
21ab4e |
- rate_lookedup);
|
|
|
21ab4e |
- gf_log (THIS->name, GF_LOG_INFO,
|
|
|
21ab4e |
"TIME: Estimated total time to complete = %"PRIu64
|
|
|
21ab4e |
- " seconds", time_to_complete);
|
|
|
21ab4e |
+ " seconds, seconds left = %"PRIu64"",
|
|
|
21ab4e |
+ time_to_complete, time_left);
|
|
|
21ab4e |
|
|
|
21ab4e |
- gf_log (THIS->name, GF_LOG_INFO,
|
|
|
21ab4e |
- "TIME: Seconds left = %"PRIu64" seconds", time_left);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
-/*END */
|
|
|
21ab4e |
if (!dict)
|
|
|
21ab4e |
goto log;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -4681,6 +4729,7 @@ gf_defrag_set_pause_state (gf_tier_conf_t *tier_conf, tier_pause_state_t state)
|
|
|
21ab4e |
pthread_mutex_unlock (&tier_conf->pause_mutex);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+
|
|
|
21ab4e |
tier_pause_state_t
|
|
|
21ab4e |
gf_defrag_get_pause_state (gf_tier_conf_t *tier_conf)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
@@ -4834,12 +4883,14 @@ gf_defrag_start_detach_tier (gf_defrag_info_t *defrag)
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
-gf_defrag_stop (gf_defrag_info_t *defrag, gf_defrag_status_t status,
|
|
|
21ab4e |
+gf_defrag_stop (dht_conf_t *conf, gf_defrag_status_t status,
|
|
|
21ab4e |
dict_t *output)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
/* TODO: set a variable 'stop_defrag' here, it should be checked
|
|
|
21ab4e |
in defrag loop */
|
|
|
21ab4e |
int ret = -1;
|
|
|
21ab4e |
+ gf_defrag_info_t *defrag = conf->defrag;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
GF_ASSERT (defrag);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (defrag->defrag_status == GF_DEFRAG_STATUS_NOT_STARTED) {
|
|
|
21ab4e |
@@ -4851,7 +4902,7 @@ gf_defrag_stop (gf_defrag_info_t *defrag, gf_defrag_status_t status,
|
|
|
21ab4e |
defrag->defrag_status = status;
|
|
|
21ab4e |
|
|
|
21ab4e |
if (output)
|
|
|
21ab4e |
- gf_defrag_status_get (defrag, output);
|
|
|
21ab4e |
+ gf_defrag_status_get (conf, output);
|
|
|
21ab4e |
ret = 0;
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
gf_msg_debug ("", 0, "Returning %d", ret);
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|