Blob Blame History Raw
From 16827311a3c04dff5f9379ff33be4802fe03b62c Mon Sep 17 00:00:00 2001
From: Joseph Fernandes <josferna@redhat.com>
Date: Tue, 26 Apr 2016 06:10:16 +0530
Subject: [PATCH 106/139] 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.

Backport of http://review.gluster.org/14068

> Change-Id: I704947bcf4bab6b20b1179a6d9ae4a15a3d51bd9
> BUG: 1330353
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>
> Reviewed-on: http://review.gluster.org/14068
> Tested-by: Joseph Fernandes
> Smoke: Gluster Build System <jenkins@build.gluster.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
> Tested-by: Dan Lambright <dlambrig@redhat.com>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>

Change-Id: I6681f3374428bb37d61688f444aeacd75649efd4
BUG: 1328721
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/73415
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
---
 xlators/cluster/dht/src/dht-common.h |    4 ++++
 xlators/cluster/dht/src/tier.c       |   21 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 369b7d4..058b149 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -395,6 +395,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 b9ed755..8166027 100644
--- a/xlators/cluster/dht/src/tier.c
+++ b/xlators/cluster/dht/src/tier.c
@@ -1362,6 +1362,9 @@ tier_migrate_files_using_qfile (demotion_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 (&current_time, NULL);
@@ -1398,6 +1401,21 @@ tier_migrate_files_using_qfile (demotion_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:
@@ -2096,6 +2114,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,
-- 
1.7.1