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