diff options
author | Joseph Fernandes <josferna@redhat.com> | 2015-12-08 18:56:31 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-12-09 09:30:45 -0800 |
commit | b7bdcc39b057ef6057778bd0ab8f36376fd76db0 (patch) | |
tree | d553c5a819ced7b0c50f41dc96deefc9cd6ba751 | |
parent | 117dce7a489624ad7a7ab6b9299b3e2c1aa0bab6 (diff) |
tier : Spawn promotion or demotion thread depending on local bricks
Spawn Promotion or Demotion depending if there are any Cold or Hot
bricks present localy.
IF the local HOT brick list is empty dont spawn demote thread.
IF the local COLD brick list is empty dont spawn promote thread.
Backport of http://review.gluster.org/12912
> Change-Id: I524730e59414dd156c78ec0bd7a3629212697e6e
> BUG: 1289578
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>
> Reviewed-on: http://review.gluster.org/12912
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: N Balachandran <nbalacha@redhat.com>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
> Tested-by: Dan Lambright <dlambrig@redhat.com>
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Change-Id: Ic3113934051c7a751ae56508e00d098d010f4c0e
BUG: 1290048
Reviewed-on: http://review.gluster.org/12928
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 426a09a71af..ed8788f97c7 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1317,25 +1317,27 @@ clear_bricklist (struct list_head *brick_list) int tier_start (xlator_t *this, gf_defrag_info_t *defrag) { - struct list_head bricklist_hot = { 0 }; - struct list_head bricklist_cold = { 0 }; - dht_conf_t *conf = NULL; - gfdb_time_t current_time; - int freq_promote = 0; - int freq_demote = 0; - promotion_args_t promotion_args = { 0 }; - demotion_args_t demotion_args = { 0 }; - int ret_promotion = 0; - int ret_demotion = 0; - int ret = 0; + struct list_head bricklist_hot = { 0 }; + struct list_head bricklist_cold = { 0 }; + gf_boolean_t is_hot_list_empty = _gf_false; + gf_boolean_t is_cold_list_empty = _gf_false; + dht_conf_t *conf = NULL; + gfdb_time_t current_time = { 0 }; + int freq_promote = 0; + int freq_demote = 0; + promotion_args_t promotion_args = { 0 }; + demotion_args_t demotion_args = { 0 }; + int ret_promotion = 0; + int ret_demotion = 0; + int ret = 0; pthread_t promote_thread; pthread_t demote_thread; - gf_boolean_t is_promotion_triggered = _gf_false; - gf_boolean_t is_demotion_triggered = _gf_false; - xlator_t *any = NULL; - xlator_t *xlator = NULL; - gf_tier_conf_t *tier_conf = NULL; - loc_t root_loc = { 0 }; + gf_boolean_t is_promotion_triggered = _gf_false; + gf_boolean_t is_demotion_triggered = _gf_false; + xlator_t *any = NULL; + xlator_t *xlator = NULL; + gf_tier_conf_t *tier_conf = NULL; + loc_t root_loc = { 0 }; conf = this->private; @@ -1345,6 +1347,9 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) tier_get_bricklist (conf->subvolumes[0], &bricklist_cold); tier_get_bricklist (conf->subvolumes[1], &bricklist_hot); + is_hot_list_empty = list_empty(&bricklist_hot); + is_cold_list_empty = list_empty(&bricklist_cold); + gf_msg (this->name, GF_LOG_INFO, 0, DHT_MSG_LOG_TIER_STATUS, "Begin run tier promote %d" " demote %d", freq_promote, freq_demote); @@ -1418,14 +1423,14 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) freq_demote = tier_get_freq_demote (tier_conf); - is_demotion_triggered = tier_check_demote (current_time, - freq_demote); + is_demotion_triggered = (is_hot_list_empty) ? _gf_false : + tier_check_demote (current_time, freq_demote); freq_promote = tier_get_freq_promote(tier_conf); - is_promotion_triggered = tier_check_promote (tier_conf, - current_time, - freq_promote); + is_promotion_triggered = (is_cold_list_empty) ? _gf_false : + tier_check_promote (tier_conf, current_time, + freq_promote); /* If no promotion and no demotion is * scheduled/triggered skip an iteration */ @@ -1443,6 +1448,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) ret_promotion = -1; ret_demotion = -1; + /* Spawn demotion thread if demotion is triggered */ if (is_demotion_triggered) { demotion_args.this = this; demotion_args.brick_list = &bricklist_hot; @@ -1459,6 +1465,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) } } + /* Spawn promotion thread if promotion is triggered */ if (is_promotion_triggered) { promotion_args.this = this; promotion_args.brick_list = &bricklist_cold; |