Blob Blame History Raw
From e172864304da1aad7776ad4b246fb039a5b7d4c0 Mon Sep 17 00:00:00 2001
From: Susant Palai <spalai@redhat.com>
Date: Thu, 5 Jan 2017 11:46:20 +0530
Subject: [PATCH 267/267] dht/rebalance: remove errno check for failure
 detection

Backport of upstream patch: http://review.gluster.org/#/c/16328/

BUG: 1405000
Change-Id: I867419ca36a81ef7209e6911a46c1c2c898b8eab
Reviewed-on: http://review.gluster.org/16328
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/94359
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/dht/src/dht-rebalance.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index ed9991f..39a7bb6 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -2435,7 +2435,7 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
                      loc_t *loc, dht_conf_t *conf, gf_defrag_info_t *defrag,
                      fd_t *fd, dict_t *migrate_data,
                      struct dir_dfmeta *dir_dfmeta, dict_t *xattr_req,
-                     int *should_commit_hash)
+                     int *should_commit_hash, int *perrno)
 {
         int                     ret             = -1;
         char                    is_linkfile     = 0;
@@ -2446,7 +2446,6 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
         struct dht_container   *tmp_container   = NULL;
         xlator_t               *hashed_subvol   = NULL;
         xlator_t               *cached_subvol   = NULL;
-        int                     fop_errno       = 0;
 
         if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
                 ret = -1;
@@ -2474,7 +2473,7 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
                                 DHT_MSG_MIGRATE_DATA_FAILED,
                                 "Readdirp failed. Aborting data migration for "
                                 "directory: %s", loc->path);
-                        fop_errno = -ret;
+                        *perrno = -ret;
                         ret = -1;
                         goto out;
                 }
@@ -2731,13 +2730,12 @@ out:
                 dict_unref (xattr_rsp);
 
 
-        errno = fop_errno;
         return ret;
 }
 
 int
 gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
-                       dict_t *migrate_data)
+                       dict_t *migrate_data, int *perrno)
 {
         int                      ret               = -1;
         fd_t                    *fd                = NULL;
@@ -2757,7 +2755,6 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
         int                      throttle_up       = 0;
         struct dir_dfmeta       *dir_dfmeta        = NULL;
         int                      should_commit_hash = 1;
-        int                      fop_errno         = 0;
 
         gf_log (this->name, GF_LOG_INFO, "migrate data called on %s",
                 loc->path);
@@ -2784,7 +2781,7 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
                         DHT_MSG_MIGRATE_DATA_FAILED,
                         "Migrate data failed: Failed to open dir %s",
                         loc->path);
-                fop_errno = -ret;
+                *perrno = -ret;
                 ret = -1;
                 goto out;
         }
@@ -2930,11 +2927,10 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
                                                    loc, conf, defrag, fd,
                                                    migrate_data, dir_dfmeta,
                                                    xattr_req,
-                                                   &should_commit_hash);
+                                                   &should_commit_hash, perrno);
 
                         if (ret) {
-                                fop_errno = errno;
-                                gf_log ("this->name", GF_LOG_WARNING, "Found "
+                                gf_log (this->name, GF_LOG_WARNING, "Found "
                                         "error from gf_defrag_get_entry");
 
                                 ret = -1;
@@ -2994,7 +2990,6 @@ out:
                 ret = 2;
         }
 
-        errno = fop_errno;
         return ret;
 }
 int
@@ -3180,6 +3175,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
         inode_t                 *linked_inode   = NULL, *inode = NULL;
         dht_conf_t              *conf           = NULL;
         int                      should_commit_hash = 1;
+        int                      perrno         = 0;
 
         conf = this->private;
         if (!conf) {
@@ -3200,7 +3196,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
                 }
 
                 if (-ret == ENOENT || -ret == ESTALE) {
-                        gf_msg (this->name, GF_LOG_INFO, errno,
+                        gf_msg (this->name, GF_LOG_INFO, -ret,
                                 DHT_MSG_DIR_LOOKUP_FAILED,
                                 "Dir:%s renamed or removed. Skipping",
                                 loc->path);
@@ -3218,10 +3214,11 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
 
         if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER) &&
             (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX)) {
-                ret = gf_defrag_process_dir (this, defrag, loc, migrate_data);
+                ret = gf_defrag_process_dir (this, defrag, loc, migrate_data,
+                                             &perrno);
 
-                if (ret && ret != 2) {
-                        if (errno == ENOENT || errno == ESTALE) {
+                if (ret && (ret != 2)) {
+                        if (perrno == ENOENT || perrno == ESTALE) {
                                 ret = 0;
                                 goto out;
                         } else {
@@ -3376,7 +3373,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
                                              NULL, NULL);
                         if (ret) {
                                 if (-ret == ENOENT || -ret == ESTALE) {
-                                        gf_msg (this->name, GF_LOG_INFO, errno,
+                                        gf_msg (this->name, GF_LOG_INFO, -ret,
                                                 DHT_MSG_DIR_LOOKUP_FAILED,
                                                 "Dir:%s renamed or removed. "
                                                 "Skipping", loc->path);
-- 
2.9.3