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