cb8e9e
From 68d405c9cc702965217ad781ff33bbf4736ebbbb Mon Sep 17 00:00:00 2001
cb8e9e
From: Nithya Balachandran <nbalacha@redhat.com>
cb8e9e
Date: Fri, 5 Jun 2015 15:28:19 +0530
cb8e9e
Subject: [PATCH 10/18] dht/rebalance : Fixed rebalance failure
cb8e9e
cb8e9e
The rebalance process determines the local subvols for the
cb8e9e
node it is running on and only acts on files in those subvols.
cb8e9e
If a dist-rep or dist-disperse volume is created on 2 nodes by
cb8e9e
dividing the bricks equally across the nodes, one process might
cb8e9e
determine it has no local_subvols.
cb8e9e
cb8e9e
When trying to update the commit hash, the function attempts to
cb8e9e
lock all local subvols. On the node with no local_subvols the dht
cb8e9e
inode lock operation fails, in turn causing the rebalance to fail.
cb8e9e
cb8e9e
In a dist-rep volume with 2 nodes, if brick 0 of each replica
cb8e9e
set is on node1 and brick 1 is on node2, node2 will find that it has
cb8e9e
no local subvols.
cb8e9e
cb8e9e
Change-Id: I7d73b5b4bf1c822eae6df2e6f79bd6a1606f4d1c
cb8e9e
BUG: 1227262
cb8e9e
Signed-off-by: Nithya Balachandran <nbalacha@redhat.com>
cb8e9e
Reviewed-on: http://review.gluster.org/10786
cb8e9e
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
cb8e9e
Reviewed-by: Susant Palai <spalai@redhat.com>
cb8e9e
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50105
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 xlators/cluster/dht/src/dht-common.c    |  5 +++--
cb8e9e
 xlators/cluster/dht/src/dht-rebalance.c | 15 ++++++++++++++-
cb8e9e
 2 files changed, 17 insertions(+), 3 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
cb8e9e
index ca68e60..e2749c9 100644
cb8e9e
--- a/xlators/cluster/dht/src/dht-common.c
cb8e9e
+++ b/xlators/cluster/dht/src/dht-common.c
cb8e9e
@@ -3535,8 +3535,6 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
cb8e9e
 
cb8e9e
         tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY);
cb8e9e
         if (tmp) {
cb8e9e
-                gf_log (this->name, GF_LOG_INFO,
cb8e9e
-                        "fixing the layout of %s", loc->path);
cb8e9e
 
cb8e9e
                 ret = dict_get_uint32(xattr, "new-commit-hash", &new_hash);
cb8e9e
                 if (ret == 0) {
cb8e9e
@@ -3554,6 +3552,9 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
cb8e9e
                         return ret;
cb8e9e
                 }
cb8e9e
 
cb8e9e
+                gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                        "fixing the layout of %s", loc->path);
cb8e9e
+
cb8e9e
                 ret = dht_fix_directory_layout (frame, dht_common_setxattr_cbk,
cb8e9e
                                                 layout);
cb8e9e
                 if (ret) {
cb8e9e
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
cb8e9e
index 6ba9dd1..3ab73d4 100644
cb8e9e
--- a/xlators/cluster/dht/src/dht-rebalance.c
cb8e9e
+++ b/xlators/cluster/dht/src/dht-rebalance.c
cb8e9e
@@ -2341,7 +2341,7 @@ gf_defrag_settle_hash (xlator_t *this, gf_defrag_info_t *defrag,
cb8e9e
                        loc_t *loc, dict_t *fix_layout)
cb8e9e
 {
cb8e9e
         int     ret;
cb8e9e
-
cb8e9e
+        dht_conf_t *conf = NULL;
cb8e9e
         /*
cb8e9e
          * Now we're ready to update the directory commit hash for the volume
cb8e9e
          * root, so that hash miscompares and broadcast lookups can stop.
cb8e9e
@@ -2355,6 +2355,19 @@ gf_defrag_settle_hash (xlator_t *this, gf_defrag_info_t *defrag,
cb8e9e
                 return 0;
cb8e9e
         }
cb8e9e
 
cb8e9e
+        conf = this->private;
cb8e9e
+        if (!conf) {
cb8e9e
+                /*Uh oh
cb8e9e
+                 */
cb8e9e
+                return -1;
cb8e9e
+        }
cb8e9e
+
cb8e9e
+        if (conf->local_subvols_cnt == 0) {
cb8e9e
+                /* Commit hash updates are only done on local subvolumes
cb8e9e
+                 */
cb8e9e
+                return 0;
cb8e9e
+        }
cb8e9e
+
cb8e9e
         ret = dict_set_uint32 (fix_layout, "new-commit-hash",
cb8e9e
                                defrag->new_commit_hash);
cb8e9e
         if (ret) {
cb8e9e
-- 
cb8e9e
1.9.3
cb8e9e