|
|
cb8e9e |
From 5d67d0a79a0986b3b547a80d6ebc3db5d70a7b77 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Dan Lambright <dlambrig@redhat.com>
|
|
|
cb8e9e |
Date: Thu, 11 Jun 2015 14:45:52 -0400
|
|
|
cb8e9e |
Subject: [PATCH 56/57] tier/dht: Fixing non atomic promotion/demotion w.r.t to frequency period
|
|
|
cb8e9e |
|
|
|
cb8e9e |
This is a backport of 11110
|
|
|
cb8e9e |
|
|
|
cb8e9e |
> This fixes the ping-pong issue i.e files getting demoted immediately
|
|
|
cb8e9e |
> after promition, caused by off-sync promotion/demotion processes.
|
|
|
cb8e9e |
> The solution is do promotion/demotion refering to the system time.
|
|
|
cb8e9e |
> To have the fix working all the file serving nodes should have
|
|
|
cb8e9e |
> thier system time synchronized with each other either manually or
|
|
|
cb8e9e |
> using a NTP Server.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
> NOTE: The ping-pong issue can re-appear even with this fix, if the admin
|
|
|
cb8e9e |
> have different promotion freq period and demotion freq period, but this
|
|
|
cb8e9e |
> would be under the control of the admin.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
> Change-Id: I1b33a5881d0cac143662ddb48e5b7b653aeb1271
|
|
|
cb8e9e |
> BUG: 1218717
|
|
|
cb8e9e |
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>
|
|
|
cb8e9e |
> Reviewed-on: http://review.gluster.org/11110
|
|
|
cb8e9e |
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: I27aa58017b75e5ba8977967176802bfb52ead656
|
|
|
cb8e9e |
BUG: 1229268
|
|
|
cb8e9e |
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/50581
|
|
|
cb8e9e |
Reviewed-by: Joseph Fernandes <josferna@redhat.com>
|
|
|
cb8e9e |
Tested-by: Joseph Fernandes <josferna@redhat.com>
|
|
|
cb8e9e |
Reviewed-by: Shyam Ranganathan <srangana@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
xlators/cluster/dht/src/tier.c | 100 +++++++++++++++++++++++++--------------
|
|
|
cb8e9e |
1 files changed, 64 insertions(+), 36 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c
|
|
|
cb8e9e |
index cef4f5c..7b4890c 100644
|
|
|
cb8e9e |
--- a/xlators/cluster/dht/src/tier.c
|
|
|
cb8e9e |
+++ b/xlators/cluster/dht/src/tier.c
|
|
|
cb8e9e |
@@ -734,7 +734,7 @@ tier_get_bricklist (xlator_t *xl, dict_t *bricklist)
|
|
|
cb8e9e |
if (!db_path) {
|
|
|
cb8e9e |
gf_msg ("tier", GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
DHT_MSG_LOG_TIER_STATUS,
|
|
|
cb8e9e |
- "Failed to allocate memory for bricklist");
|
|
|
cb8e9e |
+ "Faile. to allocate memory for bricklist");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -763,9 +763,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
dict_t *bricklist_cold = NULL;
|
|
|
cb8e9e |
dict_t *bricklist_hot = NULL;
|
|
|
cb8e9e |
dht_conf_t *conf = NULL;
|
|
|
cb8e9e |
- int tick = 0;
|
|
|
cb8e9e |
- int next_demote = 0;
|
|
|
cb8e9e |
- int next_promote = 0;
|
|
|
cb8e9e |
+ gfdb_time_t current_time;
|
|
|
cb8e9e |
int freq_promote = 0;
|
|
|
cb8e9e |
int freq_demote = 0;
|
|
|
cb8e9e |
promotion_args_t promotion_args = { 0 };
|
|
|
cb8e9e |
@@ -775,6 +773,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
int ret = 0;
|
|
|
cb8e9e |
pthread_t promote_thread;
|
|
|
cb8e9e |
pthread_t demote_thread;
|
|
|
cb8e9e |
+ gf_boolean_t is_promotion_triggered = _gf_false;
|
|
|
cb8e9e |
+ gf_boolean_t is_demotion_triggered = _gf_false;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
conf = this->private;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -789,16 +789,9 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
tier_get_bricklist (conf->subvolumes[0], bricklist_cold);
|
|
|
cb8e9e |
tier_get_bricklist (conf->subvolumes[1], bricklist_hot);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- freq_promote = defrag->tier_promote_frequency;
|
|
|
cb8e9e |
- freq_demote = defrag->tier_demote_frequency;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- next_promote = defrag->tier_promote_frequency % TIMER_SECS;
|
|
|
cb8e9e |
- next_demote = defrag->tier_demote_frequency % TIMER_SECS;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_INFO, 0,
|
|
|
cb8e9e |
- DHT_MSG_LOG_TIER_STATUS, "Begin run tier promote %d demote %d",
|
|
|
cb8e9e |
- next_promote, next_demote);
|
|
|
cb8e9e |
+ DHT_MSG_LOG_TIER_STATUS, "Begin run tier promote %d"
|
|
|
cb8e9e |
+ " demote %d", freq_promote, freq_demote);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
defrag->defrag_status = GF_DEFRAG_STATUS_STARTED;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -806,9 +799,6 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
sleep(1);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret_promotion = -1;
|
|
|
cb8e9e |
- ret_demotion = -1;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
|
|
|
cb8e9e |
ret = 1;
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
@@ -820,7 +810,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) {
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
- defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE;
|
|
|
cb8e9e |
+ defrag->defrag_status =
|
|
|
cb8e9e |
+ GF_DEFRAG_STATUS_COMPLETE;
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_DEBUG, 0,
|
|
|
cb8e9e |
DHT_MSG_LOG_TIER_ERROR,
|
|
|
cb8e9e |
"defrag->defrag_cmd == "
|
|
|
cb8e9e |
@@ -828,43 +819,75 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- tick = (tick + 1) % TIMER_SECS;
|
|
|
cb8e9e |
- if ((next_demote != tick) && (next_promote != tick))
|
|
|
cb8e9e |
+ freq_promote = defrag->tier_promote_frequency;
|
|
|
cb8e9e |
+ freq_demote = defrag->tier_demote_frequency;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ /* To have proper synchronization amongst all
|
|
|
cb8e9e |
+ * brick holding nodes, so that promotion and demotions
|
|
|
cb8e9e |
+ * start atomicly w.r.t promotion/demotion frequency
|
|
|
cb8e9e |
+ * period, all nodes should have thier system time
|
|
|
cb8e9e |
+ * in-sync with each other either manually set or
|
|
|
cb8e9e |
+ * using a NTP server*/
|
|
|
cb8e9e |
+ ret = gettimeofday (¤t_time, NULL);
|
|
|
cb8e9e |
+ if (ret == -1) {
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR,
|
|
|
cb8e9e |
+ "Failed to get current time");
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ is_demotion_triggered = ((current_time.tv_sec %
|
|
|
cb8e9e |
+ freq_demote) == 0) ? _gf_true :
|
|
|
cb8e9e |
+ _gf_false;
|
|
|
cb8e9e |
+ is_promotion_triggered = ((current_time.tv_sec %
|
|
|
cb8e9e |
+ freq_promote) == 0) ? _gf_true :
|
|
|
cb8e9e |
+ _gf_false;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ /* If no promotion and no demotion is
|
|
|
cb8e9e |
+ * scheduled/triggered skip a iteration */
|
|
|
cb8e9e |
+ if (!is_promotion_triggered && !is_demotion_triggered)
|
|
|
cb8e9e |
continue;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (next_demote >= tick) {
|
|
|
cb8e9e |
+ ret_promotion = -1;
|
|
|
cb8e9e |
+ ret_demotion = -1;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (is_demotion_triggered) {
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
demotion_args.this = this;
|
|
|
cb8e9e |
demotion_args.brick_list = bricklist_hot;
|
|
|
cb8e9e |
demotion_args.defrag = defrag;
|
|
|
cb8e9e |
demotion_args.freq_time = freq_demote;
|
|
|
cb8e9e |
- ret_demotion = pthread_create (&demote_thread, NULL,
|
|
|
cb8e9e |
- &tier_demote, &demotion_args);
|
|
|
cb8e9e |
+ ret_demotion = pthread_create (&demote_thread,
|
|
|
cb8e9e |
+ NULL, &tier_demote,
|
|
|
cb8e9e |
+ &demotion_args);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
if (ret_demotion) {
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
DHT_MSG_LOG_TIER_ERROR,
|
|
|
cb8e9e |
- "Failed starting Demotion thread!");
|
|
|
cb8e9e |
+ "Failed starting Demotion "
|
|
|
cb8e9e |
+ "thread!");
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
- freq_demote = defrag->tier_demote_frequency;
|
|
|
cb8e9e |
- next_demote = (tick + freq_demote) % TIMER_SECS;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (next_promote >= tick) {
|
|
|
cb8e9e |
+ if (is_promotion_triggered) {
|
|
|
cb8e9e |
promotion_args.this = this;
|
|
|
cb8e9e |
promotion_args.brick_list = bricklist_cold;
|
|
|
cb8e9e |
promotion_args.defrag = defrag;
|
|
|
cb8e9e |
promotion_args.freq_time = freq_promote;
|
|
|
cb8e9e |
- ret_promotion = pthread_create (&promote_thread, NULL,
|
|
|
cb8e9e |
- &tier_promote, &promotion_args);
|
|
|
cb8e9e |
+ ret_promotion = pthread_create (&promote_thread,
|
|
|
cb8e9e |
+ NULL, &tier_promote,
|
|
|
cb8e9e |
+ &promotion_args);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
if (ret_promotion) {
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
DHT_MSG_LOG_TIER_ERROR,
|
|
|
cb8e9e |
- "Failed starting Promotion thread!");
|
|
|
cb8e9e |
+ "Failed starting Promotion "
|
|
|
cb8e9e |
+ "thread!");
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
- freq_promote = defrag->tier_promote_frequency;
|
|
|
cb8e9e |
- next_promote = (tick + freq_promote) % TIMER_SECS;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (ret_demotion == 0) {
|
|
|
cb8e9e |
+ if (is_promotion_triggered && (ret_demotion == 0)) {
|
|
|
cb8e9e |
pthread_join (demote_thread, NULL);
|
|
|
cb8e9e |
if (demotion_args.return_value) {
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
@@ -874,7 +897,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
ret_demotion = demotion_args.return_value;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (ret_promotion == 0) {
|
|
|
cb8e9e |
+ if (is_demotion_triggered && (ret_promotion == 0)) {
|
|
|
cb8e9e |
pthread_join (promote_thread, NULL);
|
|
|
cb8e9e |
if (promotion_args.return_value) {
|
|
|
cb8e9e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
@@ -884,10 +907,15 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)
|
|
|
cb8e9e |
ret_promotion = promotion_args.return_value;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- /*Collect previous and current cummulative status */
|
|
|
cb8e9e |
- ret = ret | ret_demotion | ret_promotion;
|
|
|
cb8e9e |
+ /* Collect previous and current cummulative status */
|
|
|
cb8e9e |
+ /* If demotion was not triggered just pass 0 to ret */
|
|
|
cb8e9e |
+ ret = (is_demotion_triggered) ? ret_demotion : 0;
|
|
|
cb8e9e |
+ /* If promotion was not triggered just pass 0 to ret */
|
|
|
cb8e9e |
+ ret = ret | (is_promotion_triggered) ?
|
|
|
cb8e9e |
+ ret_promotion : 0;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- /*reseting promotion and demotion arguments for next iteration*/
|
|
|
cb8e9e |
+ /* reseting promotion and demotion arguments for
|
|
|
cb8e9e |
+ * next iteration*/
|
|
|
cb8e9e |
memset (&demotion_args, 0, sizeof(demotion_args_t));
|
|
|
cb8e9e |
memset (&promotion_args, 0, sizeof(promotion_args_t));
|
|
|
cb8e9e |
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|