17b94a
From 0502383024cbf7e4776816e0a992dccc484a3cf2 Mon Sep 17 00:00:00 2001
17b94a
From: Ravishankar N <ravishankar@redhat.com>
17b94a
Date: Tue, 8 Dec 2020 17:23:22 +0530
17b94a
Subject: [PATCH 488/511] glusterd/afr: enable granular-entry-heal by default
17b94a
17b94a
XXXXXXXXXXXXXXXXXXX
17b94a
    IMPORTANT:
17b94a
XXXXXXXXXXXXXXXXXXXX
17b94a
I see that for rhgs-3.5.3, GD_OP_VERSION_MAX is GD_OP_VERSION_7_0. Since
17b94a
this patch should only act on new volumes in rhgs-3.5.4, I am bumping
17b94a
the op-version to GD_OP_VERSION_7_1. In glusterfs upstream, the patch
17b94a
acts only if op-version >= GD_OP_VERSION_9_0 as seen in the commit
17b94a
messae below.
17b94a
17b94a
Upstream patch details:
17b94a
/------------------------------------------------------------------------------/
17b94a
1. The option has been enabled and tested for quite some time now in RHHI-V
17b94a
downstream and I think it is safe to make it 'on' by default. Since it
17b94a
is not possible to simply change it from 'off' to 'on' without breaking
17b94a
rolling upgrades, old clients etc., I have made it default only for new volumes
17b94a
starting from op-verison GD_OP_VERSION_9_0.
17b94a
17b94a
Note: If you do a volume reset, the option will be turned back off.
17b94a
This is okay as the dir's gfid will be captured in 'xattrop' folder  and heals
17b94a
will proceed. There might be stale entries inside entry-changes' folder,
17b94a
which will be removed when we enable the option again.
17b94a
17b94a
2. I encountered a cust. issue where entry heal was pending on a dir. with
17b94a
236436 files in it and the glustershd.log output was just stuck at
17b94a
"performing entry selfheal", so I have added logs to give us
17b94a
more info in DEBUG level about whether entry heal and data heal are
17b94a
progressing (metadata heal doesn't take much time). That way, we have a
17b94a
quick visual indication to say things are not 'stuck' if we briefly
17b94a
enable debug logs, instead of taking statedumps or checking profile info
17b94a
etc.
17b94a
17b94a
>Fixes: #1483
17b94a
>Change-Id: I4f116f8c92f8cd33f209b758ff14f3c7e1981422
17b94a
>Signed-off-by: Ravishankar N <ravishankar@redhat.com>
17b94a
Upstream Patch: https://github.com/gluster/glusterfs/pull/1621
17b94a
/------------------------------------------------------------------------------/
17b94a
17b94a
BUG: 1890506
17b94a
Change-Id: If449a1e873633616cfc508d74b5c22eb434b55ae
17b94a
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/220555
17b94a
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 libglusterfs/src/glusterfs/globals.h               |   4 +-
17b94a
 libglusterfs/src/syncop-utils.c                    |   4 +-
17b94a
 tests/basic/afr/add-brick-self-heal-non-granular.t |  75 +++++++++++++
17b94a
 tests/basic/afr/add-brick-self-heal.t              |   4 +-
17b94a
 tests/basic/afr/bug-1130892-non-granular.t         |  77 ++++++++++++++
17b94a
 .../basic/afr/bug-1493415-gfid-heal-non-granular.t |  79 ++++++++++++++
17b94a
 ...507-type-mismatch-error-handling-non-granular.t | 117 +++++++++++++++++++++
17b94a
 ...1749322-entry-heal-not-happening-non-granular.t |  90 ++++++++++++++++
17b94a
 .../afr/replace-brick-self-heal-non-granular.t     |  65 ++++++++++++
17b94a
 tests/basic/afr/replace-brick-self-heal.t          |   2 +-
17b94a
 tests/bugs/replicate/bug-1130892.t                 |   2 +-
17b94a
 tests/bugs/replicate/bug-1493415-gfid-heal.t       |   2 +-
17b94a
 .../bug-1722507-type-mismatch-error-handling.t     |  26 +++--
17b94a
 .../bug-1749322-entry-heal-not-happening.t         |   7 +-
17b94a
 xlators/cluster/afr/src/afr-self-heal-common.c     |   5 +
17b94a
 xlators/cluster/afr/src/afr-self-heal-data.c       |   3 +
17b94a
 xlators/cluster/afr/src/afr-self-heal-entry.c      |   7 +-
17b94a
 xlators/mgmt/glusterd/src/glusterd-utils.c         |  13 +++
17b94a
 18 files changed, 558 insertions(+), 24 deletions(-)
17b94a
 create mode 100644 tests/basic/afr/add-brick-self-heal-non-granular.t
17b94a
 create mode 100644 tests/basic/afr/bug-1130892-non-granular.t
17b94a
 create mode 100644 tests/basic/afr/bug-1493415-gfid-heal-non-granular.t
17b94a
 create mode 100644 tests/basic/afr/bug-1722507-type-mismatch-error-handling-non-granular.t
17b94a
 create mode 100644 tests/basic/afr/bug-1749322-entry-heal-not-happening-non-granular.t
17b94a
 create mode 100644 tests/basic/afr/replace-brick-self-heal-non-granular.t
17b94a
17b94a
diff --git a/libglusterfs/src/glusterfs/globals.h b/libglusterfs/src/glusterfs/globals.h
17b94a
index 31717ed..cc145cd 100644
17b94a
--- a/libglusterfs/src/glusterfs/globals.h
17b94a
+++ b/libglusterfs/src/glusterfs/globals.h
17b94a
@@ -50,7 +50,7 @@
17b94a
     1 /* MIN is the fresh start op-version, mostly                             \
17b94a
          should not change */
17b94a
 #define GD_OP_VERSION_MAX                                                      \
17b94a
-    GD_OP_VERSION_7_0 /* MAX VERSION is the maximum                            \
17b94a
+    GD_OP_VERSION_7_1 /* MAX VERSION is the maximum                            \
17b94a
                          count in VME table, should                            \
17b94a
                          keep changing with                                    \
17b94a
                          introduction of newer                                 \
17b94a
@@ -138,6 +138,8 @@
17b94a
 
17b94a
 #define GD_OP_VERSION_7_0 70000 /* Op-version for GlusterFS 7.0 */
17b94a
 
17b94a
+#define GD_OP_VERSION_7_1 70100 /* Op-version for GlusterFS 7.1 */
17b94a
+
17b94a
 #include "glusterfs/xlator.h"
17b94a
 #include "glusterfs/options.h"
17b94a
 
17b94a
diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c
17b94a
index be03527..2269c76 100644
17b94a
--- a/libglusterfs/src/syncop-utils.c
17b94a
+++ b/libglusterfs/src/syncop-utils.c
17b94a
@@ -495,9 +495,7 @@ syncop_dir_scan(xlator_t *subvol, loc_t *loc, int pid, void *data,
17b94a
             if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
17b94a
                 continue;
17b94a
 
17b94a
-            ret = fn(subvol, entry, loc, data);
17b94a
-            if (ret)
17b94a
-                break;
17b94a
+            ret |= fn(subvol, entry, loc, data);
17b94a
         }
17b94a
         gf_dirent_free(&entries);
17b94a
         if (ret)
17b94a
diff --git a/tests/basic/afr/add-brick-self-heal-non-granular.t b/tests/basic/afr/add-brick-self-heal-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..19caf24
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/add-brick-self-heal-non-granular.t
17b94a
@@ -0,0 +1,75 @@
17b94a
+#!/bin/bash
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+cleanup;
17b94a
+
17b94a
+TEST glusterd
17b94a
+TEST pidof glusterd
17b94a
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
17b94a
+EXPECT 'Created' volinfo_field $V0 'Status';
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+TEST $CLI volume start $V0
17b94a
+EXPECT 'Started' volinfo_field $V0 'Status';
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}0
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1
17b94a
+
17b94a
+TEST $CLI volume set $V0 cluster.data-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.metadata-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.entry-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.heal-timeout 5
17b94a
+
17b94a
+TEST $CLI volume set $V0 self-heal-daemon off
17b94a
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
17b94a
+
17b94a
+# Create files
17b94a
+for i in {1..5}
17b94a
+do
17b94a
+        echo $i > $M0/file$i.txt
17b94a
+done
17b94a
+
17b94a
+# Metadata changes
17b94a
+TEST setfattr -n user.test -v qwerty $M0/file5.txt
17b94a
+
17b94a
+# Add brick1
17b94a
+TEST $CLI volume add-brick $V0 replica 3 $H0:$B0/${V0}2
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}2
17b94a
+
17b94a
+# New-brick should accuse the old-bricks (Simulating case for data-loss)
17b94a
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}2/
17b94a
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}2/
17b94a
+
17b94a
+# Check if pending xattr and dirty-xattr are set for newly-added-brick
17b94a
+EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}0
17b94a
+EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}1
17b94a
+EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}2
17b94a
+
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 2
17b94a
+
17b94a
+TEST $CLI volume set $V0 self-heal-daemon on
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2
17b94a
+TEST $CLI volume heal $V0
17b94a
+
17b94a
+# Wait for heal to complete
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+# Check if entry-heal has happened
17b94a
+TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}2 | sort)
17b94a
+TEST diff <(ls $B0/${V0}1 | sort) <(ls $B0/${V0}2 | sort)
17b94a
+
17b94a
+# Test if data was healed
17b94a
+TEST diff $B0/${V0}0/file1.txt $B0/${V0}2/file1.txt
17b94a
+
17b94a
+# Test if metadata was healed and exists on both the bricks
17b94a
+EXPECT "qwerty" get_text_xattr user.test $B0/${V0}2/file5.txt
17b94a
+EXPECT "qwerty" get_text_xattr user.test $B0/${V0}0/file5.txt
17b94a
+
17b94a
+EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}0
17b94a
+EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}1
17b94a
+EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.dirty $B0/${V0}2
17b94a
+
17b94a
+cleanup;
17b94a
diff --git a/tests/basic/afr/add-brick-self-heal.t b/tests/basic/afr/add-brick-self-heal.t
17b94a
index c847e22..7ebf4f6 100644
17b94a
--- a/tests/basic/afr/add-brick-self-heal.t
17b94a
+++ b/tests/basic/afr/add-brick-self-heal.t
17b94a
@@ -38,8 +38,8 @@ TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0
17b94a
 TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}2/
17b94a
 
17b94a
 # Check if pending xattr and dirty-xattr are set for newly-added-brick
17b94a
-EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}0
17b94a
-EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}1
17b94a
+EXPECT "000000010000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}0
17b94a
+EXPECT "000000010000000100000001" get_hex_xattr trusted.afr.$V0-client-2 $B0/${V0}1
17b94a
 EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}2
17b94a
 
17b94a
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
diff --git a/tests/basic/afr/bug-1130892-non-granular.t b/tests/basic/afr/bug-1130892-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..3cdbc7d
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/bug-1130892-non-granular.t
17b94a
@@ -0,0 +1,77 @@
17b94a
+#!/bin/bash
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+. $(dirname $0)/../../afr.rc
17b94a
+
17b94a
+cleanup;
17b94a
+
17b94a
+TEST glusterd
17b94a
+TEST pidof glusterd
17b94a
+TEST $CLI volume info;
17b94a
+
17b94a
+# Create a 1X2 replica
17b94a
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}-{0,1}
17b94a
+EXPECT 'Created' volinfo_field $V0 'Status';
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+
17b94a
+# Disable self-heal daemon
17b94a
+TEST gluster volume set $V0 self-heal-daemon off
17b94a
+
17b94a
+# Enable Client side heal
17b94a
+TEST $CLI volume set $V0 cluster.data-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.metadata-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.entry-self-heal off
17b94a
+
17b94a
+# Disable all perf-xlators
17b94a
+TEST $CLI volume set $V0 performance.quick-read off
17b94a
+TEST $CLI volume set $V0 performance.io-cache off
17b94a
+TEST $CLI volume set $V0 performance.write-behind off
17b94a
+TEST $CLI volume set $V0 performance.stat-prefetch off
17b94a
+TEST $CLI volume set $V0 performance.read-ahead off
17b94a
+
17b94a
+# Volume start
17b94a
+TEST $CLI volume start $V0;
17b94a
+EXPECT 'Started' volinfo_field $V0 'Status';
17b94a
+
17b94a
+# FUSE Mount
17b94a
+TEST ${GFS} -s $H0 --volfile-id $V0 $M0
17b94a
+
17b94a
+# Create files and dirs
17b94a
+TEST mkdir -p $M0/one/two/
17b94a
+TEST `echo "Carpe diem" > $M0/one/two/three`
17b94a
+
17b94a
+# Simulate disk-replacement
17b94a
+TEST kill_brick $V0 $H0 $B0/${V0}-1
17b94a
+EXPECT_WITHIN ${PROCESS_DOWN_TIMEOUT} "^0$" afr_child_up_status $V0 1
17b94a
+TEST rm -rf $B0/${V0}-1/one
17b94a
+TEST rm -rf $B0/${V0}-1/.glusterfs
17b94a
+
17b94a
+#Ideally, disk replacement is done using reset-brick or replace-brick gluster CLI
17b94a
+#which will create .glusterfs folder.
17b94a
+mkdir $B0/${V0}-1/.glusterfs && chmod 600 $B0/${V0}-1/.glusterfs
17b94a
+
17b94a
+# Start force
17b94a
+TEST $CLI volume start $V0 force
17b94a
+
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+
17b94a
+TEST stat $M0/one
17b94a
+
17b94a
+sleep 1
17b94a
+
17b94a
+# Check pending xattrs
17b94a
+EXPECT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 data
17b94a
+EXPECT_NOT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 entry
17b94a
+EXPECT_NOT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 metadata
17b94a
+
17b94a
+TEST gluster volume set $V0 self-heal-daemon on
17b94a
+
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+TEST $CLI volume heal $V0
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one/two
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_file_heal_done $B0/${V0}-0 $B0/${V0}-1 one/two/three
17b94a
+
17b94a
+cleanup;
17b94a
diff --git a/tests/basic/afr/bug-1493415-gfid-heal-non-granular.t b/tests/basic/afr/bug-1493415-gfid-heal-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..aff001c
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/bug-1493415-gfid-heal-non-granular.t
17b94a
@@ -0,0 +1,79 @@
17b94a
+#!/bin/bash
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+. $(dirname $0)/../../afr.rc
17b94a
+cleanup;
17b94a
+
17b94a
+TEST glusterd
17b94a
+TEST pidof glusterd
17b94a
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+TEST $CLI volume start $V0
17b94a
+
17b94a
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 --attribute-timeout=0 --entry-timeout=0 $M0;
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+TEST $CLI volume set $V0 self-heal-daemon off
17b94a
+
17b94a
+# Create base entry in indices/xattrop
17b94a
+echo "Data" > $M0/FILE
17b94a
+
17b94a
+#------------------------------------------------------------------------------#
17b94a
+TEST touch $M0/f1
17b94a
+gfid_f1=$(gf_get_gfid_xattr $B0/${V0}0/f1)
17b94a
+gfid_str_f1=$(gf_gfid_xattr_to_str $gfid_f1)
17b94a
+
17b94a
+# Remove gfid xattr and .glusterfs hard link from 2nd brick. This simulates a
17b94a
+# brick crash at the point where file got created but no xattrs were set.
17b94a
+TEST setfattr -x trusted.gfid $B0/${V0}1/f1
17b94a
+TEST rm $B0/${V0}1/.glusterfs/${gfid_str_f1:0:2}/${gfid_str_f1:2:2}/$gfid_str_f1
17b94a
+
17b94a
+# storage/posix considers that a file without gfid changed less than a second
17b94a
+# before doesn't exist, so we need to wait for a second to force posix to
17b94a
+# consider that this is a valid file but without gfid.
17b94a
+sleep 2
17b94a
+
17b94a
+# Assume there were no pending xattrs on parent dir due to 1st brick crashing
17b94a
+# too. Then name heal from client must heal the gfid.
17b94a
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
17b94a
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 --attribute-timeout=0 --entry-timeout=0 $M0;
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+TEST stat $M0/f1
17b94a
+EXPECT "$gfid_f1" gf_get_gfid_xattr $B0/${V0}1/f1
17b94a
+TEST stat $B0/${V0}1/.glusterfs/${gfid_str_f1:0:2}/${gfid_str_f1:2:2}/$gfid_str_f1
17b94a
+
17b94a
+#------------------------------------------------------------------------------#
17b94a
+TEST mkdir $M0/dir
17b94a
+TEST touch $M0/dir/f2
17b94a
+gfid_f2=$(gf_get_gfid_xattr $B0/${V0}0/dir/f2)
17b94a
+gfid_str_f2=$(gf_gfid_xattr_to_str $gfid_f2)
17b94a
+
17b94a
+# Remove gfid xattr and .glusterfs hard link from 2nd brick. This simulates a
17b94a
+# brick crash at the point where file got created but no xattrs were set.
17b94a
+TEST setfattr -x trusted.gfid $B0/${V0}1/dir/f2
17b94a
+TEST rm $B0/${V0}1/.glusterfs/${gfid_str_f2:0:2}/${gfid_str_f2:2:2}/$gfid_str_f2
17b94a
+
17b94a
+#Now simulate setting of pending entry xattr on parent dir of 1st brick.
17b94a
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}0/dir
17b94a
+create_brick_xattrop_entry $B0/${V0}0 dir
17b94a
+
17b94a
+# storage/posix considers that a file without gfid changed less than a second
17b94a
+# before doesn't exist, so we need to wait for a second to force posix to
17b94a
+# consider that this is a valid file but without gfid.
17b94a
+sleep 2
17b94a
+
17b94a
+#Trigger entry-heal via shd
17b94a
+TEST $CLI volume set $V0 self-heal-daemon on
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+
17b94a
+TEST $CLI volume heal $V0
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+EXPECT "$gfid_f2" gf_get_gfid_xattr $B0/${V0}1/dir/f2
17b94a
+TEST stat $B0/${V0}1/.glusterfs/${gfid_str_f2:0:2}/${gfid_str_f2:2:2}/$gfid_str_f2
17b94a
+
17b94a
+#------------------------------------------------------------------------------#
17b94a
+cleanup;
17b94a
diff --git a/tests/basic/afr/bug-1722507-type-mismatch-error-handling-non-granular.t b/tests/basic/afr/bug-1722507-type-mismatch-error-handling-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..9079c93
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/bug-1722507-type-mismatch-error-handling-non-granular.t
17b94a
@@ -0,0 +1,117 @@
17b94a
+#!/bin/bash
17b94a
+
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+. $(dirname $0)/../../afr.rc
17b94a
+
17b94a
+cleanup;
17b94a
+
17b94a
+## Start and create a volume
17b94a
+TEST glusterd;
17b94a
+TEST pidof glusterd;
17b94a
+TEST $CLI volume info;
17b94a
+
17b94a
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2};
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+TEST $CLI volume start $V0;
17b94a
+TEST $CLI volume set $V0 cluster.heal-timeout 5
17b94a
+TEST $CLI volume heal $V0 disable
17b94a
+EXPECT 'Started' volinfo_field $V0 'Status';
17b94a
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
17b94a
+
17b94a
+TEST mkdir $M0/dir
17b94a
+
17b94a
+##########################################################################################
17b94a
+# GFID link file and the GFID is missing on one brick and all the bricks are being blamed.
17b94a
+
17b94a
+TEST touch $M0/dir/file
17b94a
+TEST `echo append>> $M0/dir/file`
17b94a
+
17b94a
+#B0 and B2 must blame B1
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+
17b94a
+# Add entry to xattrop dir to trigger index heal.
17b94a
+xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
+base_entry_b0=`ls $xattrop_dir0`
17b94a
+gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/))
17b94a
+ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
+EXPECT "^1$" get_pending_heal_count $V0
17b94a
+
17b94a
+# Remove the gfid xattr and the link file on one brick.
17b94a
+gfid_file=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file)
17b94a
+gfid_str_file=$(gf_gfid_xattr_to_str $gfid_file)
17b94a
+TEST setfattr -x trusted.gfid $B0/${V0}0/dir/file
17b94a
+TEST rm -f $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+
17b94a
+# Launch heal
17b94a
+TEST $CLI volume heal $V0 enable
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2
17b94a
+
17b94a
+# Wait for 2 second to force posix to consider that this is a valid file but
17b94a
+# without gfid.
17b94a
+sleep 2
17b94a
+TEST $CLI volume heal $V0
17b94a
+
17b94a
+# Heal should not fail as the file is missing gfid xattr and the link file,
17b94a
+# which is not actually the gfid or type mismatch.
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}0/dir/file
17b94a
+TEST stat $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+rm -f $M0/dir/file
17b94a
+
17b94a
+
17b94a
+###########################################################################################
17b94a
+# GFID link file and the GFID is missing on two bricks and all the bricks are being blamed.
17b94a
+
17b94a
+TEST $CLI volume heal $V0 disable
17b94a
+TEST touch $M0/dir/file
17b94a
+#TEST kill_brick $V0 $H0 $B0/$V0"1"
17b94a
+
17b94a
+#B0 and B2 must blame B1
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+
17b94a
+# Add entry to xattrop dir to trigger index heal.
17b94a
+xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
+base_entry_b0=`ls $xattrop_dir0`
17b94a
+gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/))
17b94a
+ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
+EXPECT "^1$" get_pending_heal_count $V0
17b94a
+
17b94a
+# Remove the gfid xattr and the link file on two bricks.
17b94a
+gfid_file=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file)
17b94a
+gfid_str_file=$(gf_gfid_xattr_to_str $gfid_file)
17b94a
+TEST setfattr -x trusted.gfid $B0/${V0}0/dir/file
17b94a
+TEST rm -f $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+TEST setfattr -x trusted.gfid $B0/${V0}1/dir/file
17b94a
+TEST rm -f $B0/${V0}1/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+
17b94a
+# Launch heal
17b94a
+TEST $CLI volume heal $V0 enable
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2
17b94a
+
17b94a
+# Wait for 2 second to force posix to consider that this is a valid file but
17b94a
+# without gfid.
17b94a
+sleep 2
17b94a
+TEST $CLI volume heal $V0
17b94a
+
17b94a
+# Heal should not fail as the file is missing gfid xattr and the link file,
17b94a
+# which is not actually the gfid or type mismatch.
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}0/dir/file
17b94a
+TEST stat $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}1/dir/file
17b94a
+TEST stat $B0/${V0}1/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file
17b94a
+
17b94a
+cleanup
17b94a
diff --git a/tests/basic/afr/bug-1749322-entry-heal-not-happening-non-granular.t b/tests/basic/afr/bug-1749322-entry-heal-not-happening-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..4f27da4
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/bug-1749322-entry-heal-not-happening-non-granular.t
17b94a
@@ -0,0 +1,90 @@
17b94a
+#!/bin/bash
17b94a
+
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+. $(dirname $0)/../../afr.rc
17b94a
+
17b94a
+cleanup
17b94a
+
17b94a
+function check_gfid_and_link_count
17b94a
+{
17b94a
+        local file=$1
17b94a
+
17b94a
+        file_gfid_b0=$(gf_get_gfid_xattr $B0/${V0}0/$file)
17b94a
+        TEST [ ! -z $file_gfid_b0 ]
17b94a
+        file_gfid_b1=$(gf_get_gfid_xattr $B0/${V0}1/$file)
17b94a
+        file_gfid_b2=$(gf_get_gfid_xattr $B0/${V0}2/$file)
17b94a
+        EXPECT $file_gfid_b0 echo $file_gfid_b1
17b94a
+        EXPECT $file_gfid_b0 echo $file_gfid_b2
17b94a
+
17b94a
+        EXPECT "2" stat -c %h $B0/${V0}0/$file
17b94a
+        EXPECT "2" stat -c %h $B0/${V0}1/$file
17b94a
+        EXPECT "2" stat -c %h $B0/${V0}2/$file
17b94a
+}
17b94a
+TESTS_EXPECTED_IN_LOOP=18
17b94a
+
17b94a
+################################################################################
17b94a
+## Start and create a volume
17b94a
+TEST glusterd;
17b94a
+TEST pidof glusterd;
17b94a
+TEST $CLI volume info;
17b94a
+
17b94a
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2};
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+TEST $CLI volume start $V0;
17b94a
+TEST $CLI volume set $V0 cluster.heal-timeout 5
17b94a
+TEST $CLI volume heal $V0 disable
17b94a
+EXPECT 'Started' volinfo_field $V0 'Status';
17b94a
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
17b94a
+
17b94a
+TEST mkdir $M0/dir
17b94a
+TEST `echo "File 1 " > $M0/dir/file1`
17b94a
+TEST touch $M0/dir/file{2..4}
17b94a
+
17b94a
+# Remove file2 from 1st & 3rd bricks
17b94a
+TEST rm -f $B0/$V0"0"/dir/file2
17b94a
+TEST rm -f $B0/$V0"2"/dir/file2
17b94a
+
17b94a
+# Remove file3 and the .glusterfs hardlink from 1st & 2nd bricks
17b94a
+gfid_file3=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file3)
17b94a
+gfid_str_file3=$(gf_gfid_xattr_to_str $gfid_file3)
17b94a
+TEST rm $B0/$V0"0"/.glusterfs/${gfid_str_file3:0:2}/${gfid_str_file3:2:2}/$gfid_str_file3
17b94a
+TEST rm $B0/$V0"1"/.glusterfs/${gfid_str_file3:0:2}/${gfid_str_file3:2:2}/$gfid_str_file3
17b94a
+TEST rm -f $B0/$V0"0"/dir/file3
17b94a
+TEST rm -f $B0/$V0"1"/dir/file3
17b94a
+
17b94a
+# Remove the .glusterfs hardlink and the gfid xattr of file4 on 3rd brick
17b94a
+gfid_file4=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file4)
17b94a
+gfid_str_file4=$(gf_gfid_xattr_to_str $gfid_file4)
17b94a
+TEST rm $B0/$V0"2"/.glusterfs/${gfid_str_file4:0:2}/${gfid_str_file4:2:2}/$gfid_str_file4
17b94a
+TEST setfattr -x trusted.gfid $B0/$V0"2"/dir/file4
17b94a
+
17b94a
+# B0 and B2 blame each other
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+
17b94a
+# Add entry to xattrop dir on first brick.
17b94a
+xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
+base_entry_b0=`ls $xattrop_dir0`
17b94a
+gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/))
17b94a
+TEST ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
+
17b94a
+EXPECT "^1$" get_pending_heal_count $V0
17b94a
+
17b94a
+# Launch heal
17b94a
+TEST $CLI volume heal $V0 enable
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2
17b94a
+TEST $CLI volume heal $V0
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+# All the files must be present on all the bricks after conservative merge and
17b94a
+# should have the gfid xattr and the .glusterfs hardlink.
17b94a
+check_gfid_and_link_count dir/file1
17b94a
+check_gfid_and_link_count dir/file2
17b94a
+check_gfid_and_link_count dir/file3
17b94a
+check_gfid_and_link_count dir/file4
17b94a
+
17b94a
+cleanup
17b94a
diff --git a/tests/basic/afr/replace-brick-self-heal-non-granular.t b/tests/basic/afr/replace-brick-self-heal-non-granular.t
17b94a
new file mode 100644
17b94a
index 0000000..c86bff1
17b94a
--- /dev/null
17b94a
+++ b/tests/basic/afr/replace-brick-self-heal-non-granular.t
17b94a
@@ -0,0 +1,65 @@
17b94a
+#!/bin/bash
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+cleanup;
17b94a
+
17b94a
+TEST glusterd
17b94a
+TEST pidof glusterd
17b94a
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
17b94a
+TEST $CLI volume set $V0 cluster.granular-entry-heal off
17b94a
+TEST $CLI volume start $V0
17b94a
+TEST $CLI volume set $V0 cluster.data-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.metadata-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.entry-self-heal off
17b94a
+TEST $CLI volume set $V0 cluster.heal-timeout 5
17b94a
+TEST $CLI volume set $V0 self-heal-daemon off
17b94a
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
17b94a
+
17b94a
+# Create files
17b94a
+for i in {1..5}
17b94a
+do
17b94a
+        echo $i > $M0/file$i.txt
17b94a
+done
17b94a
+
17b94a
+# Metadata changes
17b94a
+TEST setfattr -n user.test -v qwerty $M0/file5.txt
17b94a
+
17b94a
+# Replace brick1
17b94a
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force
17b94a
+
17b94a
+# Replaced-brick should accuse the non-replaced-brick (Simulating case for data-loss)
17b94a
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}1_new/
17b94a
+
17b94a
+# Check if pending xattr and dirty-xattr are set for replaced-brick
17b94a
+EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
17b94a
+EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}1_new
17b94a
+
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+
17b94a
+TEST $CLI volume set $V0 self-heal-daemon on
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+TEST $CLI volume heal $V0
17b94a
+
17b94a
+# Wait for heal to complete
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0
17b94a
+
17b94a
+# Check if entry-heal has happened
17b94a
+TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1_new | sort)
17b94a
+
17b94a
+# To make sure that files were not lost from brick0
17b94a
+TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1 | sort)
17b94a
+EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
17b94a
+
17b94a
+# Test if data was healed
17b94a
+TEST diff $B0/${V0}0/file1.txt $B0/${V0}1_new/file1.txt
17b94a
+# To make sure that data was not lost from brick0
17b94a
+TEST diff $B0/${V0}0/file1.txt $B0/${V0}1/file1.txt
17b94a
+
17b94a
+# Test if metadata was healed and exists on both the bricks
17b94a
+EXPECT "qwerty" get_text_xattr user.test $B0/${V0}1_new/file5.txt
17b94a
+EXPECT "qwerty" get_text_xattr user.test $B0/${V0}0/file5.txt
17b94a
+
17b94a
+cleanup;
17b94a
diff --git a/tests/basic/afr/replace-brick-self-heal.t b/tests/basic/afr/replace-brick-self-heal.t
17b94a
index 0360db7..da31c87 100644
17b94a
--- a/tests/basic/afr/replace-brick-self-heal.t
17b94a
+++ b/tests/basic/afr/replace-brick-self-heal.t
17b94a
@@ -30,7 +30,7 @@ TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit forc
17b94a
 TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}1_new/
17b94a
 
17b94a
 # Check if pending xattr and dirty-xattr are set for replaced-brick
17b94a
-EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
17b94a
+EXPECT "000000010000000100000001" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
17b94a
 EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}1_new
17b94a
 
17b94a
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
diff --git a/tests/bugs/replicate/bug-1130892.t b/tests/bugs/replicate/bug-1130892.t
17b94a
index 0f57d66..e23eb26 100644
17b94a
--- a/tests/bugs/replicate/bug-1130892.t
17b94a
+++ b/tests/bugs/replicate/bug-1130892.t
17b94a
@@ -56,7 +56,7 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
 TEST stat $M0/one
17b94a
 
17b94a
 # Check pending xattrs
17b94a
-EXPECT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 data
17b94a
+EXPECT "00000001" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 data
17b94a
 EXPECT_NOT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 entry
17b94a
 EXPECT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 metadata
17b94a
 
17b94a
diff --git a/tests/bugs/replicate/bug-1493415-gfid-heal.t b/tests/bugs/replicate/bug-1493415-gfid-heal.t
17b94a
index 125c35a..9714d5e 100644
17b94a
--- a/tests/bugs/replicate/bug-1493415-gfid-heal.t
17b94a
+++ b/tests/bugs/replicate/bug-1493415-gfid-heal.t
17b94a
@@ -49,7 +49,7 @@ TEST setfattr -x trusted.gfid $B0/${V0}1/dir/f2
17b94a
 TEST rm $B0/${V0}1/.glusterfs/${gfid_str_f2:0:2}/${gfid_str_f2:2:2}/$gfid_str_f2
17b94a
 
17b94a
 #Now simulate setting of pending entry xattr on parent dir of 1st brick.
17b94a
-TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}0/dir
17b94a
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000001 $B0/${V0}0/dir
17b94a
 create_brick_xattrop_entry $B0/${V0}0 dir
17b94a
 
17b94a
 #Trigger entry-heal via shd
17b94a
diff --git a/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t b/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t
17b94a
index 0aeaaaf..1fdf7ea 100644
17b94a
--- a/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t
17b94a
+++ b/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t
17b94a
@@ -23,19 +23,21 @@ TEST mkdir $M0/dir
17b94a
 ##########################################################################################
17b94a
 # GFID link file and the GFID is missing on one brick and all the bricks are being blamed.
17b94a
 
17b94a
-TEST touch $M0/dir/file
17b94a
-#TEST kill_brick $V0 $H0 $B0/$V0"1"
17b94a
+TEST `echo append>> $M0/dir/file`
17b94a
 
17b94a
 #B0 and B2 must blame B1
17b94a
-setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
-setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
-setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+# Set data part of the xattr also to 1 so that local->need_full_crawl is true.
17b94a
+# Another way is to create the needed entries inside indices/entry-changes
17b94a
+# folder.
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000001 $B0/$V0"0"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000001 $B0/$V0"0"/dir
17b94a
 
17b94a
 # Add entry to xattrop dir to trigger index heal.
17b94a
 xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
 base_entry_b0=`ls $xattrop_dir0`
17b94a
 gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/))
17b94a
-ln -s $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
+ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
 EXPECT "^1$" get_pending_heal_count $V0
17b94a
 
17b94a
 # Remove the gfid xattr and the link file on one brick.
17b94a
@@ -70,18 +72,20 @@ rm -f $M0/dir/file
17b94a
 
17b94a
 TEST $CLI volume heal $V0 disable
17b94a
 TEST touch $M0/dir/file
17b94a
-#TEST kill_brick $V0 $H0 $B0/$V0"1"
17b94a
 
17b94a
 #B0 and B2 must blame B1
17b94a
-setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
-setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
-setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+# Set data part of the xattr also to 1 so that local->need_full_crawl is true.
17b94a
+# Another way is to create the needed entries inside indices/entry-changes
17b94a
+# folder.
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000001 $B0/$V0"0"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000001 $B0/$V0"0"/dir
17b94a
 
17b94a
 # Add entry to xattrop dir to trigger index heal.
17b94a
 xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
 base_entry_b0=`ls $xattrop_dir0`
17b94a
 gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/))
17b94a
-ln -s $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
+ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str
17b94a
 EXPECT "^1$" get_pending_heal_count $V0
17b94a
 
17b94a
 # Remove the gfid xattr and the link file on two bricks.
17b94a
diff --git a/tests/bugs/replicate/bug-1749322-entry-heal-not-happening.t b/tests/bugs/replicate/bug-1749322-entry-heal-not-happening.t
17b94a
index 9627908..3da873a 100644
17b94a
--- a/tests/bugs/replicate/bug-1749322-entry-heal-not-happening.t
17b94a
+++ b/tests/bugs/replicate/bug-1749322-entry-heal-not-happening.t
17b94a
@@ -59,8 +59,11 @@ TEST rm $B0/$V0"2"/.glusterfs/${gfid_str_file4:0:2}/${gfid_str_file4:2:2}/$gfid_
17b94a
 TEST setfattr -x trusted.gfid $B0/$V0"2"/dir/file4
17b94a
 
17b94a
 # B0 and B2 blame each other
17b94a
-setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir
17b94a
-setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir
17b94a
+# Set data part of the xattr also to 1 so that local->need_full_crawl is true.
17b94a
+# Another way is to create the needed entries inside indices/entry-changes
17b94a
+# folder.
17b94a
+setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000001 $B0/$V0"2"/dir
17b94a
+setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000001 $B0/$V0"0"/dir
17b94a
 
17b94a
 # Add entry to xattrop dir on first brick.
17b94a
 xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
17b94a
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
17b94a
index 1608f75..36fd3a9 100644
17b94a
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
17b94a
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
17b94a
@@ -2549,6 +2549,11 @@ afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid)
17b94a
         }
17b94a
     }
17b94a
 
17b94a
+    gf_msg_debug(
17b94a
+        this->name, 0,
17b94a
+        "heals needed for %s: [entry-heal=%d, metadata-heal=%d, data-heal=%d]",
17b94a
+        uuid_utoa(gfid), entry_selfheal, metadata_selfheal, data_selfheal);
17b94a
+
17b94a
     if (data_selfheal && priv->data_self_heal)
17b94a
         data_ret = afr_selfheal_data(frame, this, fd);
17b94a
 
17b94a
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
17b94a
index cdff4a5..b97c66b 100644
17b94a
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
17b94a
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
17b94a
@@ -239,6 +239,9 @@ afr_selfheal_data_block(call_frame_t *frame, xlator_t *this, fd_t *fd,
17b94a
     sink_count = AFR_COUNT(healed_sinks, priv->child_count);
17b94a
     data_lock = alloca0(priv->child_count);
17b94a
 
17b94a
+    gf_msg_debug(this->name, 0, "gfid:%s, offset=%jd, size=%zu",
17b94a
+                 uuid_utoa(fd->inode->gfid), offset, size);
17b94a
+
17b94a
     ret = afr_selfheal_inodelk(frame, this, fd->inode, this->name, offset, size,
17b94a
                                data_lock);
17b94a
     {
17b94a
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
17b94a
index 40be898..00b5b2d 100644
17b94a
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
17b94a
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
17b94a
@@ -206,8 +206,11 @@ __afr_selfheal_heal_dirent(call_frame_t *frame, xlator_t *this, fd_t *fd,
17b94a
                                             replies);
17b94a
         } else {
17b94a
             if (!gf_uuid_compare(replies[i].poststat.ia_gfid,
17b94a
-                                 replies[source].poststat.ia_gfid))
17b94a
+                                 replies[source].poststat.ia_gfid)) {
17b94a
+                gf_msg_debug(this->name, 0, "skipping %s, no heal needed.",
17b94a
+                             name);
17b94a
                 continue;
17b94a
+            }
17b94a
 
17b94a
             ret = afr_selfheal_recreate_entry(frame, i, source, sources,
17b94a
                                               fd->inode, name, inode, replies);
17b94a
@@ -839,7 +842,7 @@ afr_selfheal_entry_granular_dirent(xlator_t *subvol, gf_dirent_t *entry,
17b94a
 
17b94a
 out:
17b94a
     loc_wipe(&loc;;
17b94a
-    return 0;
17b94a
+    return ret;
17b94a
 }
17b94a
 
17b94a
 static int
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
index a72c494..bd17a82 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
@@ -13181,6 +13181,19 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
17b94a
             goto out;
17b94a
         }
17b94a
     }
17b94a
+
17b94a
+    if ((conf->op_version >= GD_OP_VERSION_7_1) &&
17b94a
+        (volinfo->status == GLUSTERD_STATUS_NONE)) {
17b94a
+        ret = dict_set_dynstr_with_alloc(volinfo->dict,
17b94a
+                                         "cluster.granular-entry-heal", "on");
17b94a
+        if (ret) {
17b94a
+            gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
17b94a
+                   "Failed to set option 'cluster.granular-entry-heal' "
17b94a
+                   "on volume %s",
17b94a
+                   volinfo->volname);
17b94a
+            goto out;
17b94a
+        }
17b94a
+    }
17b94a
 out:
17b94a
     return ret;
17b94a
 }
17b94a
-- 
17b94a
1.8.3.1
17b94a