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