233933
From 8cc721ee43ac8038eecb712278378710ad0745ed Mon Sep 17 00:00:00 2001
233933
From: root <root@localhost.localdomain>
233933
Date: Sun, 7 Apr 2019 19:31:17 +0530
233933
Subject: [PATCH 146/169] dht: Custom xattrs are not healed in case of
233933
 add-brick
233933
233933
Problem: If any custom xattrs are set on the directory before
233933
         add a brick, xattrs are not healed on the directory
233933
         after adding a brick.
233933
233933
Solution: xattr are not healed because dht_selfheal_dir_mkdir_lookup_cbk
233933
          checks the value of MDS and if MDS value is not negative
233933
          selfheal code path does not take reference of MDS xattrs.Change the
233933
          condition to take reference of MDS xattr so that custom xattrs are
233933
          populated on newly added brick
233933
233933
> Updates: bz#1702299
233933
> Change-Id: Id14beedb98cce6928055f294e1594b22132e811c
233933
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
233933
> (Cherry pick from commit aa52259de7b50625b754ce9fb5c0f38e22d79dd6)
233933
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22520/)
233933
233933
BUG: 1702298
233933
Change-Id: Id14beedb98cce6928055f294e1594b22132e811c
233933
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/171591
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
233933
---
233933
 tests/bugs/bug-1702299.t               | 67 ++++++++++++++++++++++++++++++++++
233933
 xlators/cluster/dht/src/dht-selfheal.c |  9 +----
233933
 2 files changed, 68 insertions(+), 8 deletions(-)
233933
 create mode 100644 tests/bugs/bug-1702299.t
233933
233933
diff --git a/tests/bugs/bug-1702299.t b/tests/bugs/bug-1702299.t
233933
new file mode 100644
233933
index 0000000..1cff2ed
233933
--- /dev/null
233933
+++ b/tests/bugs/bug-1702299.t
233933
@@ -0,0 +1,67 @@
233933
+#!/bin/bash
233933
+. $(dirname $0)/../include.rc
233933
+. $(dirname $0)/../volume.rc
233933
+. $(dirname $0)/../dht.rc
233933
+cleanup;
233933
+
233933
+function get_getfattr {
233933
+        local path=$1
233933
+        echo `getfattr -n user.foo $path` | cut -f2 -d"=" | sed -e 's/^"//'  -e 's/"$//'
233933
+}
233933
+
233933
+function set_fattr {
233933
+        for i in `seq 1 10`
233933
+        do
233933
+                setfattr -n user.foo -v "newabc" ./tmp${i}
233933
+                if [ "$?" = "0" ]
233933
+                 then
233933
+                    succ=$((succ+1))
233933
+                else
233933
+                    fail=$((fail+1))
233933
+                fi
233933
+        done
233933
+}
233933
+
233933
+
233933
+
233933
+TEST glusterd
233933
+TEST pidof glusterd
233933
+TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1,2,3}
233933
+TEST $CLI volume start $V0
233933
+
233933
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 --attribute-timeout=0 $M0;
233933
+
233933
+cd $M0
233933
+TEST mkdir tmp{1..10}
233933
+
233933
+succ=fail=0
233933
+## set user.foo xattr with value newabc after kill one brick
233933
+set_fattr
233933
+count=10
233933
+EXPECT "$succ" echo $count
233933
+count=0
233933
+EXPECT "$fail" echo $count
233933
+
233933
+cd -
233933
+
233933
+# Add-brick
233933
+TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{4,5}
233933
+
233933
+cd $M0
233933
+## At this point dht code will heal xattr on down brick only for those dirs
233933
+## hashed subvol was up at the time of update xattr
233933
+TEST stat ./tmp{1..10}
233933
+
233933
+
233933
+## Count the user.foo xattr value with newabc on brick and compare with succ value
233933
+count=`getfattr -n user.foo $B0/${V0}4/tmp{1..10} | grep "user.foo" | grep -iw "newabc" | wc -l`
233933
+EXPECT "$succ" echo $count
233933
+
233933
+## Count the user.foo xattr value with newabc on brick and compare with succ value
233933
+count=`getfattr -n user.foo $B0/${V0}5/tmp{1..10} | grep "user.foo" | grep -iw "newabc" | wc -l`
233933
+EXPECT "$succ" echo $count
233933
+
233933
+
233933
+cd -
233933
+TEST umount $M0
233933
+cleanup
233933
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
233933
index 5420fca..f5dfff9 100644
233933
--- a/xlators/cluster/dht/src/dht-selfheal.c
233933
+++ b/xlators/cluster/dht/src/dht-selfheal.c
233933
@@ -1310,12 +1310,8 @@ dht_selfheal_dir_mkdir_lookup_cbk(call_frame_t *frame, void *cookie,
233933
     int this_call_cnt = 0;
233933
     int missing_dirs = 0;
233933
     dht_layout_t *layout = NULL;
233933
-    dht_conf_t *conf = 0;
233933
     xlator_t *prev = 0;
233933
     loc_t *loc = NULL;
233933
-    int check_mds = 0;
233933
-    int errst = 0;
233933
-    int32_t mds_xattr_val[1] = {0};
233933
     char gfid_local[GF_UUID_BUF_SIZE] = {0};
233933
     int index = -1;
233933
 
233933
@@ -1324,7 +1320,6 @@ dht_selfheal_dir_mkdir_lookup_cbk(call_frame_t *frame, void *cookie,
233933
     local = frame->local;
233933
     layout = local->layout;
233933
     loc = &local->loc;
233933
-    conf = this->private;
233933
     prev = cookie;
233933
 
233933
     if (!gf_uuid_is_null(local->gfid))
233933
@@ -1347,9 +1342,7 @@ dht_selfheal_dir_mkdir_lookup_cbk(call_frame_t *frame, void *cookie,
233933
 
233933
         if (!op_ret) {
233933
             dht_iatt_merge(this, &local->stbuf, stbuf);
233933
-            check_mds = dht_dict_get_array(xattr, conf->mds_xattr_key,
233933
-                                           mds_xattr_val, 1, &errst);
233933
-            if (dict_get(xattr, conf->mds_xattr_key) && check_mds && !errst) {
233933
+            if (prev == local->mds_subvol) {
233933
                 dict_unref(local->xattr);
233933
                 local->xattr = dict_ref(xattr);
233933
             }
233933
-- 
233933
1.8.3.1
233933