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