From 9fbcf7f862df50925c3e2b83740c30ccd55e80dd Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Fri, 22 Jan 2016 17:31:48 -0500 Subject: cluster/tier: break out of iterating query file once cycle time ends When iterating the query file during migration, tiering should break out of the loop once cycle time completes. Otherwise it may be possible to stay in the loop for a long time. If that happens updates to files will become stale and have not impact migration. This is a backport of 13284 > Change-Id: Ib60cf74bc84e8646e6a0da21ff04954b1b83c414 > BUG: 1301227 > Signed-off-by: Dan Lambright > Reviewed-on: http://review.gluster.org/13284 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System Signed-off-by: Dan Lambright Change-Id: Ia305784b0aa570b70e54f532bf5d68a91b0cf305 BUG: 1318203 Reviewed-on: http://review.gluster.org/13750 Smoke: Gluster Build System Reviewed-by: hari gowtham Tested-by: Dan Lambright NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Dan Lambright --- xlators/cluster/dht/src/tier.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index b14f0063265..b9ed7550b2c 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -457,6 +457,10 @@ tier_migrate_using_query_file (void *_args) uint64_t total_migrated_bytes = 0; int total_files = 0; loc_t root_loc = { 0 }; + gfdb_time_t start_time = { 0 }; + gfdb_time_t current_time = { 0 }; + int total_time = 0; + int max_time = 0; GF_VALIDATE_OR_GOTO ("tier", query_cbk_args, out); @@ -494,6 +498,13 @@ tier_migrate_using_query_file (void *_args) } + ret = gettimeofday (&start_time, NULL); + if (query_cbk_args->is_promotion) { + max_time = defrag->tier_conf.tier_promote_frequency; + } else { + max_time = defrag->tier_conf.tier_demote_frequency; + } + /* Per file */ while ((ret = read_query_record_list (query_cbk_args->qfile_array, &query_record)) != 0) { @@ -506,6 +517,22 @@ tier_migrate_using_query_file (void *_args) goto out; } + ret = gettimeofday (¤t_time, NULL); + if (ret < 0) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_ERROR, + "Could not get current time."); + goto out; + } + + total_time = current_time.tv_sec - start_time.tv_sec; + if (total_time > max_time) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_STATUS, + "Max cycle time reached. Exiting migration."); + goto out; + } + per_file_status = 0; per_link_status = 0; -- cgit