diff options
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 27 |
1 files changed, 27 insertions, 0 deletions
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; |