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