diff options
Diffstat (limited to 'xlators/cluster')
-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; |