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