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