887953
From aad0d32376e6ca56770e5c2d4dc5a1462b1e7167 Mon Sep 17 00:00:00 2001
887953
From: N Balachandran <nbalacha@redhat.com>
887953
Date: Thu, 13 Dec 2018 12:06:10 +0530
887953
Subject: [PATCH 457/493] cluster/dht: sync brick root perms on add brick
887953
887953
If a single brick is added to the volume and the
887953
newly added brick is the first to respond to a
887953
dht_revalidate call, its stbuf will not be merged
887953
into local->stbuf as the brick does not yet have
887953
a layout. The is_permission_different check therefore
887953
fails to detect that an attr heal is required as it
887953
only considers the stbuf values from existing bricks.
887953
To fix this, merge all stbuf values into local->stbuf
887953
and use local->prebuf to store the correct directory
887953
attributes.
887953
887953
upstream patch: https://review.gluster.org/#/c/glusterfs/+/21611/
887953
887953
> Change-Id: Ic9e8b04a1ab9ed1248b6b056e3450bbafe32e1bc
887953
> fixes: bz#1648298
887953
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
887953
887953
Change-Id: I329ce48555d15f741d7247290e749f0800d12df8
887953
BUG: 1648296
887953
Signed-off-by: N Balachandran <nbalacha@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/158493
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Susant Palai <spalai@redhat.com>
887953
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
887953
---
887953
 tests/bugs/distribute/bug-1368012.t  | 11 +++++------
887953
 xlators/cluster/dht/src/dht-common.c | 26 ++++++++------------------
887953
 2 files changed, 13 insertions(+), 24 deletions(-)
887953
887953
diff --git a/tests/bugs/distribute/bug-1368012.t b/tests/bugs/distribute/bug-1368012.t
887953
index b861554..0b62635 100644
887953
--- a/tests/bugs/distribute/bug-1368012.t
887953
+++ b/tests/bugs/distribute/bug-1368012.t
887953
@@ -15,7 +15,7 @@ TEST pidof glusterd;
887953
 TEST $CLI volume info;
887953
 
887953
 ## Lets create volume
887953
-TEST $CLI volume create $V0 $H0:/${V0}{1,2};
887953
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
887953
 
887953
 ## Verify volume is created
887953
 EXPECT "$V0" volinfo_field $V0 'Volume Name';
887953
@@ -36,17 +36,16 @@ TEST chmod 444 $M0
887953
 TEST permission_root=`stat -c "%A" $M0`
887953
 TEST echo $permission_root
887953
 #Add-brick
887953
-TEST $CLI volume add-brick $V0 $H0:/${V0}3
887953
+TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
887953
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" online_brick_count
887953
 
887953
 #Allow one lookup to happen
887953
-TEST pushd $M0
887953
-TEST ls
887953
+TEST ls $M0
887953
 #Generate another lookup
887953
 echo 3 > /proc/sys/vm/drop_caches
887953
-TEST ls
887953
+TEST ls $M0
887953
 #check root permission
887953
 EXPECT_WITHIN "5" $permission_root get_permission $M0
887953
 #check permission on the new-brick
887953
-EXPECT $permission_root get_permission /${V0}3
887953
+EXPECT $permission_root get_permission $B0/${V0}3
887953
 cleanup
887953
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
887953
index d3a0c8b..2e19036 100644
887953
--- a/xlators/cluster/dht/src/dht-common.c
887953
+++ b/xlators/cluster/dht/src/dht-common.c
887953
@@ -1717,14 +1717,17 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
887953
                 if (is_dir) {
887953
                         ret = dht_dir_has_layout (xattr, conf->xattr_name);
887953
                         if (ret >= 0) {
887953
-                                if (is_greater_time(local->stbuf.ia_ctime,
887953
-                                                    local->stbuf.ia_ctime_nsec,
887953
+                                if (is_greater_time(local->prebuf.ia_ctime,
887953
+                                                    local->prebuf.ia_ctime_nsec,
887953
                                                     stbuf->ia_ctime,
887953
                                                     stbuf->ia_ctime_nsec)) {
887953
                                         /* Choose source */
887953
                                         local->prebuf.ia_gid = stbuf->ia_gid;
887953
                                         local->prebuf.ia_uid = stbuf->ia_uid;
887953
 
887953
+                                        local->prebuf.ia_ctime = stbuf->ia_ctime;
887953
+                                        local->prebuf.ia_ctime_nsec = stbuf->ia_ctime_nsec;
887953
+
887953
                                         if (__is_root_gfid (stbuf->ia_gfid))
887953
                                                 local->prebuf.ia_prot = stbuf->ia_prot;
887953
                                 }
887953
@@ -1792,22 +1795,9 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
887953
                         }
887953
                 }
887953
 
887953
-
887953
-                /* Update stbuf from the servers where layout is present. This
887953
-                 * is an indication that the server is not a newly added brick.
887953
-                 * Merging stbuf from newly added brick may result in the added
887953
-                 * brick being the source of heal for uid/gid */
887953
-                if (!is_dir || (is_dir &&
887953
-                    dht_dir_has_layout (xattr, conf->xattr_name) >= 0)
887953
-                    || conf->subvolume_cnt == 1) {
887953
-
887953
-                        dht_iatt_merge (this, &local->stbuf, stbuf, prev);
887953
-                        dht_iatt_merge (this, &local->postparent, postparent,
887953
-                                        prev);
887953
-                } else {
887953
-                        /* copy the gfid anyway */
887953
-                        gf_uuid_copy (local->stbuf.ia_gfid, stbuf->ia_gfid);
887953
-                }
887953
+                gf_uuid_copy (local->stbuf.ia_gfid, stbuf->ia_gfid);
887953
+                dht_iatt_merge (this, &local->stbuf, stbuf, prev);
887953
+                dht_iatt_merge (this, &local->postparent, postparent, prev);
887953
 
887953
                 local->op_ret = 0;
887953
 
887953
-- 
887953
1.8.3.1
887953