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