14f8ab
From bde1ad97f8739f8370a2bbb92229b1b397ecd82c Mon Sep 17 00:00:00 2001
14f8ab
From: karthik-us <ksubrahm@redhat.com>
14f8ab
Date: Tue, 8 Dec 2020 19:06:03 +0530
14f8ab
Subject: [PATCH 492/511] afr/lookup: Pass xattr_req in while doing a selfheal
14f8ab
 in lookup
14f8ab
14f8ab
We were not passing xattr_req when doing a name self heal
14f8ab
as well as a meta data heal. Because of this, some xdata
14f8ab
was missing which causes i/o errors
14f8ab
14f8ab
Upstream patch details:
14f8ab
> Change-Id: Ibfb1205a7eb0195632dc3820116ffbbb8043545f
14f8ab
> Fixes: bz#1728770
14f8ab
> Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
Upstream Patch : https://review.gluster.org/#/c/glusterfs/+/23024/
14f8ab
14f8ab
BUG: 1726673
14f8ab
Change-Id: Ibfb1205a7eb0195632dc3820116ffbbb8043545f
14f8ab
Signed-off-by: karthik-us <ksubrahm@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/220538
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 tests/bugs/replicate/bug-1728770-pass-xattrs.t | 52 ++++++++++++++++++++++++++
14f8ab
 tests/include.rc                               |  1 +
14f8ab
 xlators/cluster/afr/src/afr-common.c           |  8 +++-
14f8ab
 xlators/cluster/afr/src/afr-self-heal-common.c |  9 ++++-
14f8ab
 xlators/cluster/afr/src/afr-self-heal.h        |  2 +-
14f8ab
 5 files changed, 67 insertions(+), 5 deletions(-)
14f8ab
 create mode 100644 tests/bugs/replicate/bug-1728770-pass-xattrs.t
14f8ab
14f8ab
diff --git a/tests/bugs/replicate/bug-1728770-pass-xattrs.t b/tests/bugs/replicate/bug-1728770-pass-xattrs.t
14f8ab
new file mode 100644
14f8ab
index 0000000..159c4fc
14f8ab
--- /dev/null
14f8ab
+++ b/tests/bugs/replicate/bug-1728770-pass-xattrs.t
14f8ab
@@ -0,0 +1,52 @@
14f8ab
+#!/bin/bash
14f8ab
+
14f8ab
+. $(dirname $0)/../../include.rc
14f8ab
+. $(dirname $0)/../../volume.rc
14f8ab
+. $(dirname $0)/../../snapshot.rc
14f8ab
+
14f8ab
+cleanup;
14f8ab
+
14f8ab
+function fop_on_bad_disk {
14f8ab
+    local path=$1
14f8ab
+    mkdir $path/dir{1..1000} 2>/dev/null
14f8ab
+    mv $path/dir1 $path/newdir
14f8ab
+    touch $path/foo.txt
14f8ab
+    echo $?
14f8ab
+}
14f8ab
+
14f8ab
+function ls_fop_on_bad_disk {
14f8ab
+    local path=$1
14f8ab
+    ls $path
14f8ab
+    echo $?
14f8ab
+}
14f8ab
+
14f8ab
+TEST init_n_bricks 6;
14f8ab
+TEST setup_lvm 6;
14f8ab
+
14f8ab
+TEST glusterd;
14f8ab
+TEST pidof glusterd;
14f8ab
+
14f8ab
+TEST $CLI volume create $V0 replica 3 $H0:$L1 $H0:$L2 $H0:$L3 $H0:$L4 $H0:$L5 $H0:$L6;
14f8ab
+TEST $CLI volume set $V0 health-check-interval 1000;
14f8ab
+
14f8ab
+TEST $CLI volume start $V0;
14f8ab
+
14f8ab
+TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0;
14f8ab
+#corrupt last disk
14f8ab
+dd if=/dev/urandom of=/dev/mapper/patchy_snap_vg_6-brick_lvm bs=512K count=200 status=progress && sync
14f8ab
+
14f8ab
+
14f8ab
+# Test the disk is now returning EIO for touch and ls
14f8ab
+EXPECT_WITHIN $DISK_FAIL_TIMEOUT "^1$" fop_on_bad_disk "$L6"
14f8ab
+EXPECT_WITHIN $DISK_FAIL_TIMEOUT "^2$" ls_fop_on_bad_disk "$L6"
14f8ab
+
14f8ab
+TEST touch $M0/foo{1..100}
14f8ab
+TEST $CLI volume remove-brick $V0 replica 3 $H0:$L4 $H0:$L5 $H0:$L6 start
14f8ab
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0" "$H0:$L4 $H0:$L5 $H0:$L6";
14f8ab
+
14f8ab
+#check that remove-brick status should not have any failed or skipped files
14f8ab
+var=`$CLI volume remove-brick $V0 $H0:$L4 $H0:$L5 $H0:$L6 status | grep completed`
14f8ab
+TEST [ `echo $var | awk '{print $5}'` = "0"  ]
14f8ab
+TEST [ `echo $var | awk '{print $6}'` = "0"  ]
14f8ab
+
14f8ab
+cleanup;
14f8ab
diff --git a/tests/include.rc b/tests/include.rc
14f8ab
index 762c5e2..c925941 100644
14f8ab
--- a/tests/include.rc
14f8ab
+++ b/tests/include.rc
14f8ab
@@ -89,6 +89,7 @@ GRAPH_SWITCH_TIMEOUT=10
14f8ab
 UNLINK_TIMEOUT=5
14f8ab
 MDC_TIMEOUT=5
14f8ab
 IO_WAIT_TIMEOUT=5
14f8ab
+DISK_FAIL_TIMEOUT=80
14f8ab
 
14f8ab
 LOGDIR=$(gluster --print-logdir)
14f8ab
 
14f8ab
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
14f8ab
index 851ccad..fca2cd5 100644
14f8ab
--- a/xlators/cluster/afr/src/afr-common.c
14f8ab
+++ b/xlators/cluster/afr/src/afr-common.c
14f8ab
@@ -2609,6 +2609,10 @@ afr_lookup_sh_metadata_wrap(void *opaque)
14f8ab
     dict = dict_new();
14f8ab
     if (!dict)
14f8ab
         goto out;
14f8ab
+    if (local->xattr_req) {
14f8ab
+        dict_copy(local->xattr_req, dict);
14f8ab
+    }
14f8ab
+
14f8ab
     ret = dict_set_sizen_str_sizen(dict, "link-count", GF_XATTROP_INDEX_COUNT);
14f8ab
     if (ret) {
14f8ab
         gf_msg_debug(this->name, -ret, "Unable to set link-count in dict ");
14f8ab
@@ -2617,7 +2621,7 @@ afr_lookup_sh_metadata_wrap(void *opaque)
14f8ab
     if (loc_is_nameless(&local->loc)) {
14f8ab
         ret = afr_selfheal_unlocked_discover_on(frame, local->inode,
14f8ab
                                                 local->loc.gfid, local->replies,
14f8ab
-                                                local->child_up);
14f8ab
+                                                local->child_up, dict);
14f8ab
     } else {
14f8ab
         inode = afr_selfheal_unlocked_lookup_on(frame, local->loc.parent,
14f8ab
                                                 local->loc.name, local->replies,
14f8ab
@@ -2791,7 +2795,7 @@ afr_lookup_selfheal_wrap(void *opaque)
14f8ab
 
14f8ab
     inode = afr_selfheal_unlocked_lookup_on(frame, local->loc.parent,
14f8ab
                                             local->loc.name, local->replies,
14f8ab
-                                            local->child_up, NULL);
14f8ab
+                                            local->child_up, local->xattr_req);
14f8ab
     if (inode)
14f8ab
         inode_unref(inode);
14f8ab
 
14f8ab
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
14f8ab
index 36fd3a9..9b6575f 100644
14f8ab
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
14f8ab
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
14f8ab
@@ -1861,7 +1861,7 @@ afr_set_multi_dom_lock_count_request(xlator_t *this, dict_t *dict)
14f8ab
 int
14f8ab
 afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
14f8ab
                                   uuid_t gfid, struct afr_reply *replies,
14f8ab
-                                  unsigned char *discover_on)
14f8ab
+                                  unsigned char *discover_on, dict_t *dict)
14f8ab
 {
14f8ab
     loc_t loc = {
14f8ab
         0,
14f8ab
@@ -1876,6 +1876,8 @@ afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
14f8ab
     xattr_req = dict_new();
14f8ab
     if (!xattr_req)
14f8ab
         return -ENOMEM;
14f8ab
+    if (dict)
14f8ab
+        dict_copy(dict, xattr_req);
14f8ab
 
14f8ab
     if (afr_xattr_req_prepare(frame->this, xattr_req) != 0) {
14f8ab
         dict_unref(xattr_req);
14f8ab
@@ -1906,11 +1908,14 @@ afr_selfheal_unlocked_discover(call_frame_t *frame, inode_t *inode, uuid_t gfid,
14f8ab
                                struct afr_reply *replies)
14f8ab
 {
14f8ab
     afr_local_t *local = NULL;
14f8ab
+    dict_t *dict = NULL;
14f8ab
 
14f8ab
     local = frame->local;
14f8ab
+    if (local && local->xattr_req)
14f8ab
+        dict = local->xattr_req;
14f8ab
 
14f8ab
     return afr_selfheal_unlocked_discover_on(frame, inode, gfid, replies,
14f8ab
-                                             local->child_up);
14f8ab
+                                             local->child_up, dict);
14f8ab
 }
14f8ab
 
14f8ab
 unsigned int
14f8ab
diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h
14f8ab
index b39af02..8f6fb00 100644
14f8ab
--- a/xlators/cluster/afr/src/afr-self-heal.h
14f8ab
+++ b/xlators/cluster/afr/src/afr-self-heal.h
14f8ab
@@ -188,7 +188,7 @@ afr_selfheal_unlocked_discover(call_frame_t *frame, inode_t *inode, uuid_t gfid,
14f8ab
 int
14f8ab
 afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
14f8ab
                                   uuid_t gfid, struct afr_reply *replies,
14f8ab
-                                  unsigned char *discover_on);
14f8ab
+                                  unsigned char *discover_on, dict_t *dict);
14f8ab
 inode_t *
14f8ab
 afr_selfheal_unlocked_lookup_on(call_frame_t *frame, inode_t *parent,
14f8ab
                                 const char *name, struct afr_reply *replies,
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab