a3470f
From 8863bc3638ca8b3a2c6105d35f5a9113b5796dd5 Mon Sep 17 00:00:00 2001
a3470f
From: Susant Palai <spalai@redhat.com>
a3470f
Date: Mon, 21 May 2018 11:51:47 +0530
a3470f
Subject: [PATCH 296/305] cluster/dht: Increase failure count for lookup
a3470f
 failure in remove-brick op
a3470f
a3470f
An entry from readdirp might get renamed just before migration leading to
a3470f
lookup failures. For such lookup failure, remove-brick process does not
a3470f
see any increment in failure count. Though there is a warning message
a3470f
after remove-brick commit for the user to check in the decommissioned brick
a3470f
for any files those are not migrated, it's better to increase the failure count
a3470f
so that user can check in the decommissioned bricks for files before commit.
a3470f
a3470f
Note: This can result in false negative cases for rm -rf interaction with
a3470f
remove-brick op, where remove-brick shows non-zero failed count, but the
a3470f
entry was actually deleted by user.
a3470f
a3470f
upstream patch: https://review.gluster.org/#/c/20044/
a3470f
> Fixes :bz#1580269
a3470f
> Change-Id: Icd1047ab9edc1d5bfc231a1f417a7801c424917c
a3470f
> fixes: bz#1580269
a3470f
> Signed-off-by: Susant Palai <spalai@redhat.com>
a3470f
a3470f
Change-Id: Icd1047ab9edc1d5bfc231a1f417a7801c424917c
a3470f
BUG: 1577051
a3470f
(cherry-picked from upstream: https://review.gluster.org/#/c/20044/)
a3470f
Signed-off-by: Susant Palai <spalai@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/139989
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 xlators/cluster/dht/src/dht-rebalance.c | 34 ++++++++++++++++++++++++++++++---
a3470f
 1 file changed, 31 insertions(+), 3 deletions(-)
a3470f
a3470f
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
a3470f
index f03931f..b9078e0 100644
a3470f
--- a/xlators/cluster/dht/src/dht-rebalance.c
a3470f
+++ b/xlators/cluster/dht/src/dht-rebalance.c
a3470f
@@ -2713,6 +2713,19 @@ gf_defrag_migrate_single_file (void *opaque)
a3470f
                         DHT_MSG_MIGRATE_FILE_FAILED,
a3470f
                         "Migrate file failed: %s lookup failed",
a3470f
                         entry_loc.path);
a3470f
+
a3470f
+                /* Increase failure count only for remove-brick op, so that
a3470f
+                 * user is warned to check the removed-brick for any files left
a3470f
+                 * unmigrated
a3470f
+                 */
a3470f
+                if (conf->decommission_subvols_cnt) {
a3470f
+                        LOCK (&defrag->lock);
a3470f
+                        {
a3470f
+                                defrag->total_failures += 1;
a3470f
+                        }
a3470f
+                        UNLOCK (&defrag->lock);
a3470f
+                }
a3470f
+
a3470f
                 ret = 0;
a3470f
                 goto out;
a3470f
         }
a3470f
@@ -3722,8 +3735,11 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
a3470f
                                 DHT_MSG_DIR_LOOKUP_FAILED,
a3470f
                                 "Dir:%s renamed or removed. Skipping",
a3470f
                                 loc->path);
a3470f
-                                ret = 0;
a3470f
-                                goto out;
a3470f
+                        if (conf->decommission_subvols_cnt) {
a3470f
+                                defrag->total_failures++;
a3470f
+                        }
a3470f
+                        ret = 0;
a3470f
+                        goto out;
a3470f
                 } else {
a3470f
                         gf_msg (this->name, GF_LOG_ERROR, -ret,
a3470f
                                 DHT_MSG_DIR_LOOKUP_FAILED,
a3470f
@@ -3744,6 +3760,9 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
a3470f
         ret = syncop_opendir (this, loc, fd, NULL, NULL);
a3470f
         if (ret) {
a3470f
                 if (-ret == ENOENT || -ret == ESTALE) {
a3470f
+                        if (conf->decommission_subvols_cnt) {
a3470f
+                                defrag->total_failures++;
a3470f
+                        }
a3470f
                         ret = 0;
a3470f
                         goto out;
a3470f
                 }
a3470f
@@ -3763,6 +3782,9 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
a3470f
         {
a3470f
                 if (ret < 0) {
a3470f
                         if (-ret == ENOENT || -ret == ESTALE) {
a3470f
+                                if (conf->decommission_subvols_cnt) {
a3470f
+                                        defrag->total_failures++;
a3470f
+                                }
a3470f
                                 ret = 0;
a3470f
                                 goto out;
a3470f
                         }
a3470f
@@ -3868,7 +3890,10 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
a3470f
                                                 DHT_MSG_DIR_LOOKUP_FAILED,
a3470f
                                                 "Dir:%s renamed or removed. "
a3470f
                                                 "Skipping", loc->path);
a3470f
-                                                ret = 0;
a3470f
+                                        ret = 0;
a3470f
+                                        if (conf->decommission_subvols_cnt) {
a3470f
+                                                defrag->total_failures++;
a3470f
+                                        }
a3470f
                                         continue;
a3470f
                                 } else {
a3470f
                                         gf_msg (this->name, GF_LOG_ERROR, -ret,
a3470f
@@ -3931,6 +3956,9 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
a3470f
                                 "Setxattr failed. Dir %s "
a3470f
                                 "renamed or removed",
a3470f
                                 loc->path);
a3470f
+                        if (conf->decommission_subvols_cnt) {
a3470f
+                                defrag->total_failures++;
a3470f
+                        }
a3470f
                         ret = 0;
a3470f
                 } else {
a3470f
                         gf_msg (this->name, GF_LOG_ERROR, -ret,
a3470f
-- 
a3470f
1.8.3.1
a3470f