14f8ab
From b603170ae5f583037b8177a9d19e56c7821edf0b Mon Sep 17 00:00:00 2001
14f8ab
From: Pranith Kumar K <pkarampu@redhat.com>
14f8ab
Date: Tue, 25 Aug 2020 04:19:54 +0530
14f8ab
Subject: [PATCH 466/466] cluster/ec: Change stale index handling
14f8ab
14f8ab
Problem:
14f8ab
Earlier approach is setting dirty bit which requires extra heal
14f8ab
14f8ab
Fix:
14f8ab
Send zero-xattrop which deletes stale index without any need
14f8ab
for extra heal.
14f8ab
14f8ab
 > Fixes: #1385
14f8ab
 > Upstream-patch: https://review.gluster.org/c/glusterfs/+/24911/
14f8ab
14f8ab
BUG: 1785714
14f8ab
Change-Id: I7e97a1d8b5516f7be47cae55d0e56b14332b6cae
14f8ab
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/209904
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Tested-by: Ashish Pandey <aspandey@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 xlators/cluster/ec/src/ec-heal.c | 14 +++++---------
14f8ab
 1 file changed, 5 insertions(+), 9 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
14f8ab
index 6e6948b..06bafa5 100644
14f8ab
--- a/xlators/cluster/ec/src/ec-heal.c
14f8ab
+++ b/xlators/cluster/ec/src/ec-heal.c
14f8ab
@@ -2490,7 +2490,7 @@ out:
14f8ab
 }
14f8ab
 
14f8ab
 int
14f8ab
-ec_heal_set_dirty_without_lock(call_frame_t *frame, ec_t *ec, inode_t *inode)
14f8ab
+ec_heal_purge_stale_index(call_frame_t *frame, ec_t *ec, inode_t *inode)
14f8ab
 {
14f8ab
     int i = 0;
14f8ab
     int ret = 0;
14f8ab
@@ -2520,7 +2520,6 @@ ec_heal_set_dirty_without_lock(call_frame_t *frame, ec_t *ec, inode_t *inode)
14f8ab
         xattr[i] = dict;
14f8ab
         on[i] = 1;
14f8ab
     }
14f8ab
-    dirty_xattr[EC_METADATA_TXN] = hton64(1);
14f8ab
     ret = dict_set_static_bin(dict, EC_XATTR_DIRTY, dirty_xattr,
14f8ab
                               (sizeof(*dirty_xattr) * EC_VERSION_SIZE));
14f8ab
     if (ret < 0) {
14f8ab
@@ -2621,13 +2620,10 @@ ec_heal_do(xlator_t *this, void *data, loc_t *loc, int32_t partial)
14f8ab
             gf_msg(ec->xl->name, GF_LOG_INFO, 0, EC_MSG_HEAL_FAIL,
14f8ab
                    "Index entry needs to be purged for: %s ",
14f8ab
                    uuid_utoa(loc->gfid));
14f8ab
-            /* We need to send xattrop to set dirty flag so that it can be
14f8ab
-             * healed and index entry could be removed. We need not to take lock
14f8ab
-             * on this entry to do so as we are just setting dirty flag which
14f8ab
-             * actually increases the trusted.ec.dirty count and does not set
14f8ab
-             * the new value.
14f8ab
-             * This will make sure that it is not interfering in other fops.*/
14f8ab
-            ec_heal_set_dirty_without_lock(frame, ec, loc->inode);
14f8ab
+            /* We need to send zero-xattrop so that stale index entry could be
14f8ab
+             * removed. We need not take lock on this entry to do so as
14f8ab
+             * xattrop on a brick is atomic. */
14f8ab
+            ec_heal_purge_stale_index(frame, ec, loc->inode);
14f8ab
         } else if (need_heal == EC_HEAL_NONEED) {
14f8ab
             gf_msg(ec->xl->name, GF_LOG_DEBUG, 0, EC_MSG_HEAL_FAIL,
14f8ab
                    "Heal is not required for : %s ", uuid_utoa(loc->gfid));
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab