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