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