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