From 0d23f5207337fa54be57939eb8d70fe835d4658b Mon Sep 17 00:00:00 2001 From: Joseph Fernandes Date: Tue, 26 Apr 2016 06:10:16 +0530 Subject: tier/migrator: Fetch the next query file for the next cycle Problem: When we spawn promote and demote thread, query files are build. And only query file with index 0 is picked for migration as the first query file. This may not be suitable for scenarios, where the file in the query are too big to move in the first cycle, as a result file in the other query files always get missed. We need to shuffle so that other query files also get a chance. Fix: Remember the previous first query file and shift it by one index, before the migration starts. Change-Id: I704947bcf4bab6b20b1179a6d9ae4a15a3d51bd9 BUG: 1330353 Signed-off-by: Joseph Fernandes Reviewed-on: http://review.gluster.org/14068 Tested-by: Joseph Fernandes Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Dan Lambright Tested-by: Dan Lambright NetBSD-regression: NetBSD Build System --- xlators/cluster/dht/src/dht-common.h | 4 ++++ xlators/cluster/dht/src/tier.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 1dfc5cddaea..a240a72444d 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -391,6 +391,10 @@ typedef struct gf_tier_conf { int demote_in_progress; /* This Structure is only used in tiering fixlayout */ gf_tier_fix_layout_arg_t tier_fix_layout_arg; + /* Indicates the index of the first queryfile picked + * in the last cycle of promote or demote */ + int32_t last_promote_qfile_index; + int32_t last_demote_qfile_index; } gf_tier_conf_t; struct gf_defrag_info_ { diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index b99497bc66a..1484589bc47 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1404,6 +1404,9 @@ tier_migrate_files_using_qfile (migration_args_t *comp, ssize_t qfile_array_size = 0; int count = 0; int temp_fd = 0; + gf_tier_conf_t *tier_conf = NULL; + + tier_conf = &(query_cbk_args->defrag->tier_conf); /* Time format for error query files */ gettimeofday (¤t_time, NULL); @@ -1440,6 +1443,21 @@ tier_migrate_files_using_qfile (migration_args_t *comp, count++; } + /* Moving the query file index to the next, so that we won't the same + * query file every cycle as the first one */ + query_cbk_args->qfile_array->next_index = + (query_cbk_args->is_promotion) ? + tier_conf->last_promote_qfile_index : + tier_conf->last_demote_qfile_index; + shift_next_index (query_cbk_args->qfile_array); + if (query_cbk_args->is_promotion) { + tier_conf->last_promote_qfile_index = + query_cbk_args->qfile_array->next_index; + } else { + tier_conf->last_demote_qfile_index = + query_cbk_args->qfile_array->next_index; + } + /* Migrate files using query file list */ ret = tier_migrate_using_query_file ((void *)query_cbk_args); out: @@ -2139,6 +2157,9 @@ tier_init (xlator_t *this) defrag = conf->defrag; + defrag->tier_conf.last_demote_qfile_index = 0; + defrag->tier_conf.last_promote_qfile_index = 0; + defrag->tier_conf.is_tier = 1; ret = dict_get_int32 (this->options, -- cgit