summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2015-12-08 18:56:31 +0530
committerDan Lambright <dlambrig@redhat.com>2015-12-09 05:34:09 -0800
commitbcc4c12360c1a63bae5b787e519a35c32b48ae83 (patch)
tree08419c67f46ff15881a4a4f48c46c824f79593e2 /xlators/cluster/dht
parent8424674e7046136728e5f43adb19bb1fa5b19f5a (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. Signed-off-by: Joseph Fernandes <josferna@redhat.com> 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>
Diffstat (limited to 'xlators/cluster/dht')
-rw-r--r--xlators/cluster/dht/src/tier.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c
index 450f8e070fd..d9bc4e9a0b2 100644
--- a/xlators/cluster/dht/src/tier.c
+++ b/xlators/cluster/dht/src/tier.c
@@ -1316,25 +1316,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;
@@ -1344,6 +1346,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);
@@ -1417,14 +1422,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 */
@@ -1442,6 +1447,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;
@@ -1458,6 +1464,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;