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