summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-11-09 17:06:22 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2018-12-26 16:40:30 +0000
commite2f1bd54bd675e126e195d81a67b1d4331b77551 (patch)
tree90847a23e474c9b17b3b6b28554887ead2a51c0e
parent0beca839679d437d49c7481cb7370e1350f16ba9 (diff)
cluster/dht: sync brick root perms on add brick
If a single brick is added to the volume and the newly added brick is the first to respond to a dht_revalidate call, its stbuf will not be merged into local->stbuf as the brick does not yet have a layout. The is_permission_different check therefore fails to detect that an attr heal is required as it only considers the stbuf values from existing bricks. To fix this, merge all stbuf values into local->stbuf and use local->prebuf to store the correct directory attributes. Change-Id: Ic9e8b04a1ab9ed1248b6b056e3450bbafe32e1bc fixes: bz#1660736 Signed-off-by: N Balachandran <nbalacha@redhat.com>
-rw-r--r--tests/bugs/distribute/bug-1368012.t11
-rw-r--r--xlators/cluster/dht/src/dht-common.c25
2 files changed, 14 insertions, 22 deletions
diff --git a/tests/bugs/distribute/bug-1368012.t b/tests/bugs/distribute/bug-1368012.t
index b8615549ad9..0b626353aab 100644
--- a/tests/bugs/distribute/bug-1368012.t
+++ b/tests/bugs/distribute/bug-1368012.t
@@ -15,7 +15,7 @@ TEST pidof glusterd;
TEST $CLI volume info;
## Lets create volume
-TEST $CLI volume create $V0 $H0:/${V0}{1,2};
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
## Verify volume is created
EXPECT "$V0" volinfo_field $V0 'Volume Name';
@@ -36,17 +36,16 @@ TEST chmod 444 $M0
TEST permission_root=`stat -c "%A" $M0`
TEST echo $permission_root
#Add-brick
-TEST $CLI volume add-brick $V0 $H0:/${V0}3
+TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" online_brick_count
#Allow one lookup to happen
-TEST pushd $M0
-TEST ls
+TEST ls $M0
#Generate another lookup
echo 3 > /proc/sys/vm/drop_caches
-TEST ls
+TEST ls $M0
#check root permission
EXPECT_WITHIN "5" $permission_root get_permission $M0
#check permission on the new-brick
-EXPECT $permission_root get_permission /${V0}3
+EXPECT $permission_root get_permission $B0/${V0}3
cleanup
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index f43a10bec2f..16a4786c12a 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1620,13 +1620,16 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
if (is_dir) {
ret = dht_dir_has_layout(xattr, conf->xattr_name);
if (ret >= 0) {
- if (is_greater_time(local->stbuf.ia_ctime,
- local->stbuf.ia_ctime_nsec, stbuf->ia_ctime,
- stbuf->ia_ctime_nsec)) {
+ if (is_greater_time(local->prebuf.ia_ctime,
+ local->prebuf.ia_ctime_nsec,
+ stbuf->ia_ctime, stbuf->ia_ctime_nsec)) {
/* Choose source */
local->prebuf.ia_gid = stbuf->ia_gid;
local->prebuf.ia_uid = stbuf->ia_uid;
+ local->prebuf.ia_ctime = stbuf->ia_ctime;
+ local->prebuf.ia_ctime_nsec = stbuf->ia_ctime_nsec;
+
if (__is_root_gfid(stbuf->ia_gfid))
local->prebuf.ia_prot = stbuf->ia_prot;
}
@@ -1688,19 +1691,9 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
}
}
- /* Update stbuf from the servers where layout is present. This
- * is an indication that the server is not a newly added brick.
- * Merging stbuf from newly added brick may result in the added
- * brick being the source of heal for uid/gid */
- if (!is_dir ||
- (is_dir && dht_dir_has_layout(xattr, conf->xattr_name) >= 0) ||
- conf->subvolume_cnt == 1) {
- dht_iatt_merge(this, &local->stbuf, stbuf);
- dht_iatt_merge(this, &local->postparent, postparent);
- } else {
- /* copy the gfid anyway */
- gf_uuid_copy(local->stbuf.ia_gfid, stbuf->ia_gfid);
- }
+ gf_uuid_copy(local->stbuf.ia_gfid, stbuf->ia_gfid);
+ dht_iatt_merge(this, &local->stbuf, stbuf);
+ dht_iatt_merge(this, &local->postparent, postparent);
local->op_ret = 0;