3604df
From bf4003ca869d951ff173d908885be89ef63ba28e Mon Sep 17 00:00:00 2001
3604df
From: N Balachandran <nbalacha@redhat.com>
3604df
Date: Thu, 8 Sep 2016 09:34:46 +0530
3604df
Subject: [PATCH 74/86] cluster/dht: Skip layout overlap maximization on weighted rebalance
3604df
3604df
During a fix-layout, dht_selfheal_layout_maximize_overlap () does not
3604df
consider chunk sizes while calculating layout overlaps, causing smaller
3604df
bricks to sometimes get larger ranges than larger bricks. Temporarily
3604df
enabling this operation if only if weighted rebalance is disabled
3604df
or all bricks are the same size.
3604df
3604df
> Change-Id: I5ed16cdff2551b826a1759ca8338921640bfc7b3
3604df
> BUG: 1366494
3604df
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
3604df
> Reviewed-on: http://review.gluster.org/15403
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
3604df
>Reviewed-on: http://review.gluster.org/15422
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Niels de Vos <ndevos@redhat.com>
3604df
3604df
Change-Id: Icf0dd83f36912e721982bcf818a06c4b339dc974
3604df
BUG: 1257182
3604df
Signed-off-by: N Balachandran <nbalacha@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/84881
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Tested-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 tests/bugs/distribute/bug-853258.t     |    1 +
3604df
 xlators/cluster/dht/src/dht-selfheal.c |   25 +++++++++++++++++++++----
3604df
 2 files changed, 22 insertions(+), 4 deletions(-)
3604df
3604df
diff --git a/tests/bugs/distribute/bug-853258.t b/tests/bugs/distribute/bug-853258.t
3604df
index 2f0e1b8..e39f507 100755
3604df
--- a/tests/bugs/distribute/bug-853258.t
3604df
+++ b/tests/bugs/distribute/bug-853258.t
3604df
@@ -17,6 +17,7 @@ mkdir -p $H0:$B0/${V0}3
3604df
 TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2
3604df
 TEST $CLI volume start $V0
3604df
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status';
3604df
+TEST $CLI volume set $V0 cluster.weighted-rebalance off
3604df
 
3604df
 # Force assignment of initial ranges.
3604df
 TEST $CLI volume rebalance $V0 fix-layout start
3604df
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
3604df
index f43a235..fd90e54 100644
3604df
--- a/xlators/cluster/dht/src/dht-selfheal.c
3604df
+++ b/xlators/cluster/dht/src/dht-selfheal.c
3604df
@@ -1706,6 +1706,7 @@ dht_fix_layout_of_directory (call_frame_t *frame, loc_t *loc,
3604df
         dht_local_t  *local        = NULL;
3604df
         uint32_t      subvol_down  = 0;
3604df
         int           ret          = 0;
3604df
+        gf_boolean_t  maximize_overlap = _gf_true;
3604df
 
3604df
         this  = frame->this;
3604df
         priv  = this->private;
3604df
@@ -1752,9 +1753,18 @@ dht_fix_layout_of_directory (call_frame_t *frame, loc_t *loc,
3604df
                                 "subvolume %d (%s): %u chunks", i,
3604df
                                 priv->subvolumes[i]->name,
3604df
                                 priv->du_stats[i].chunks);
3604df
+
3604df
+                        /* Maximize overlap if the bricks are all the same
3604df
+                         *  size.
3604df
+                         * This is probably not going to be very common on
3604df
+                         * live setups but will benefit our regression tests
3604df
+                         */
3604df
+                        if (i && (priv->du_stats[i].chunks
3604df
+                                  != priv->du_stats[0].chunks)) {
3604df
+                                maximize_overlap = _gf_false;
3604df
+                        }
3604df
                 }
3604df
-        }
3604df
-        else {
3604df
+        } else {
3604df
                 gf_msg (this->name, GF_LOG_WARNING, 0,
3604df
                         DHT_MSG_NO_DISK_USAGE_STATUS, "no du stats ?!?");
3604df
         }
3604df
@@ -1764,9 +1774,16 @@ dht_fix_layout_of_directory (call_frame_t *frame, loc_t *loc,
3604df
         dht_layout_sort_volname (new_layout);
3604df
 	dht_selfheal_layout_new_directory (frame, loc, new_layout);
3604df
 
3604df
-	/* Now selectively re-assign ranges only when it helps */
3604df
-	dht_selfheal_layout_maximize_overlap (frame, loc, new_layout, layout);
3604df
 
3604df
+        /* Maximize overlap if weighted-rebalance is disabled */
3604df
+        if (!priv->do_weighting)
3604df
+                maximize_overlap = _gf_true;
3604df
+
3604df
+	/* Now selectively re-assign ranges only when it helps */
3604df
+        if (maximize_overlap) {
3604df
+                dht_selfheal_layout_maximize_overlap (frame, loc, new_layout,
3604df
+                                                      layout);
3604df
+        }
3604df
 done:
3604df
         if (new_layout) {
3604df
                 /* Now that the new layout has all the proper layout, change the
3604df
-- 
3604df
1.7.1
3604df