14f8ab
From e772bef5631017145cd0270d72a9ada1378e022a Mon Sep 17 00:00:00 2001
14f8ab
From: Barak Sason Rofman <bsasonro@redhat.com>
14f8ab
Date: Fri, 30 Oct 2020 08:27:47 +0200
14f8ab
Subject: [PATCH 478/478] DHT - Fixing rebalance failure on issuing stop
14f8ab
 command
14f8ab
14f8ab
Issuing a stop command for an ongoing rebalance process results in an error.
14f8ab
This issue was brought up in https://bugzilla.redhat.com/1286171 and a patch
14f8ab
(https://review.gluster.org/24103/) was submitted to resolve the issue.
14f8ab
14f8ab
However the submitted patch resolved only part of the
14f8ab
problem by reducing the number of log messages that were printed (since
14f8ab
rebalnace is currently a recursive process, an error message was printed
14f8ab
for every directory) but didn't fully resolve the root cause for the
14f8ab
failure.
14f8ab
14f8ab
This patch fixes the issue by modifying the code-path which handles the
14f8ab
termination of the rebalance process by issuing a stop command.
14f8ab
14f8ab
Upstream:
14f8ab
> Reviewed-on: https://github.com/gluster/glusterfs/pull/1628
14f8ab
> fixes: #1627
14f8ab
> Change-Id: I604f2b0f8b1ccb1026b8425a14200bbd1dc5bd03
14f8ab
> Signed-off-by: Barak Sason Rofman bsasonro@redhat.com
14f8ab
14f8ab
BUG: 1286171
14f8ab
Change-Id: I604f2b0f8b1ccb1026b8425a14200bbd1dc5bd03
14f8ab
Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/216896
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 xlators/cluster/dht/src/dht-rebalance.c | 22 ++++++++++++----------
14f8ab
 1 file changed, 12 insertions(+), 10 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
14f8ab
index abc10fc..d49a719 100644
14f8ab
--- a/xlators/cluster/dht/src/dht-rebalance.c
14f8ab
+++ b/xlators/cluster/dht/src/dht-rebalance.c
14f8ab
@@ -3113,12 +3113,10 @@ int static gf_defrag_get_entry(xlator_t *this, int i,
14f8ab
     struct dht_container *tmp_container = NULL;
14f8ab
 
14f8ab
     if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
14f8ab
-        ret = -1;
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
     if (dir_dfmeta->offset_var[i].readdir_done == 1) {
14f8ab
-        ret = 0;
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
@@ -3135,7 +3133,6 @@ int static gf_defrag_get_entry(xlator_t *this, int i,
14f8ab
                               &(dir_dfmeta->equeue[i]), xattr_req, NULL);
14f8ab
         if (ret == 0) {
14f8ab
             dir_dfmeta->offset_var[i].readdir_done = 1;
14f8ab
-            ret = 0;
14f8ab
             goto out;
14f8ab
         }
14f8ab
 
14f8ab
@@ -3161,7 +3158,6 @@ int static gf_defrag_get_entry(xlator_t *this, int i,
14f8ab
 
14f8ab
     while (1) {
14f8ab
         if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
14f8ab
-            ret = -1;
14f8ab
             goto out;
14f8ab
         }
14f8ab
 
14f8ab
@@ -3273,12 +3269,14 @@ int static gf_defrag_get_entry(xlator_t *this, int i,
14f8ab
     }
14f8ab
 
14f8ab
 out:
14f8ab
-    if (ret == 0) {
14f8ab
-        *container = tmp_container;
14f8ab
-    } else {
14f8ab
-        if (tmp_container) {
14f8ab
+    if (defrag->defrag_status == GF_DEFRAG_STATUS_STARTED) {
14f8ab
+        if (ret == 0) {
14f8ab
+            *container = tmp_container;
14f8ab
+        } else {
14f8ab
             gf_defrag_free_container(tmp_container);
14f8ab
         }
14f8ab
+    } else {
14f8ab
+        gf_defrag_free_container(tmp_container);
14f8ab
     }
14f8ab
 
14f8ab
     return ret;
14f8ab
@@ -3487,7 +3485,7 @@ gf_defrag_process_dir(xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
14f8ab
                                       migrate_data, dir_dfmeta, xattr_req,
14f8ab
                                       &should_commit_hash, perrno);
14f8ab
 
14f8ab
-            if (defrag->defrag_status == GF_DEFRAG_STATUS_STOPPED) {
14f8ab
+            if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
14f8ab
                 goto out;
14f8ab
             }
14f8ab
 
14f8ab
@@ -3947,7 +3945,7 @@ gf_defrag_fix_layout(xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
14f8ab
             ret = gf_defrag_fix_layout(this, defrag, &entry_loc, fix_layout,
14f8ab
                                        migrate_data);
14f8ab
 
14f8ab
-            if (defrag->defrag_status == GF_DEFRAG_STATUS_STOPPED) {
14f8ab
+            if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
14f8ab
                 goto out;
14f8ab
             }
14f8ab
 
14f8ab
@@ -4015,6 +4013,10 @@ gf_defrag_fix_layout(xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
14f8ab
         (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX)) {
14f8ab
         ret = gf_defrag_process_dir(this, defrag, loc, migrate_data, &perrno);
14f8ab
 
14f8ab
+        if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
14f8ab
+            goto out;
14f8ab
+        }
14f8ab
+
14f8ab
         if (ret && (ret != 2)) {
14f8ab
             if (perrno == ENOENT || perrno == ESTALE) {
14f8ab
                 ret = 0;
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab