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