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