From a278c2aecedfbe17e2749109d73b292ca25ff439 Mon Sep 17 00:00:00 2001 From: Anders Blomdell Date: Tue, 29 Jul 2014 17:11:20 +0200 Subject: Symlink mtime changes when rebalancing Added mtime preservation for special files during rebalance. Change-Id: If04921d4d66853fde8b4d8a3ab748790864f8f42 BUG: 1122443 Signed-off-by: Anders Blomdell Reviewed-on: http://review.gluster.org/8383 Tested-by: Gluster Build System Reviewed-by: Shyamsundar Ranganathan Reviewed-by: Harshavardhana Reviewed-by: Anand Avati --- tests/bugs/bug-1122443.t | 59 +++++++++++++++++++++++++++++++++ xlators/cluster/dht/src/dht-rebalance.c | 3 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/bug-1122443.t diff --git a/tests/bugs/bug-1122443.t b/tests/bugs/bug-1122443.t new file mode 100644 index 00000000000..711b70cccca --- /dev/null +++ b/tests/bugs/bug-1122443.t @@ -0,0 +1,59 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../dht.rc + +make_files() { + mkdir $1 && \ + ln -s ../ $1/symlink && \ + mknod $1/special_b b 1 2 && \ + mknod $1/special_c c 3 4 && \ + mknod $1/special_u u 5 6 && \ + mknod $1/special_p p && \ + touch -h --date=@1 $1/symlink && \ + touch -h --date=@2 $1/special_b && + touch -h --date=@3 $1/special_c && + touch -h --date=@4 $1/special_u && + touch -h --date=@5 $1/special_p +} + +bug_1113050_workaround() { + # Test if graph change has settled (bug-1113050?) + test=$(stat --printf "%n:%Y," $1 2>&1) + if [ $? -eq 0 ] ; then + echo RECONNECTED + else + echo WAITING + fi + return 0 +} + +cleanup + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 +TEST $CLI volume start $V0 + +# Mount FUSE and create symlink +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST make_files $M0/subdir + +# Get mtime before migration +BEFORE="$(stat --printf "%n:%Y," $M0/subdir/*)" + +# Migrate brick +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}1 +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}0 start +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" remove_brick_completed +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}0 commit + +# Get mtime after migration +EXPECT_WITHIN 5 RECONNECTED bug_1113050_workaround $M0/subdir/* +AFTER="$(stat --printf "%n:%Y," $M0/subdir/*)" + +# Check if mtime is unchanged +TEST [ "$AFTER" == "$BEFORE" ] + +cleanup diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 96bc02075cb..365099b9e0b 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -817,7 +817,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc, done: ret = syncop_setattr (to, loc, buf, - (GF_SET_ATTR_UID | GF_SET_ATTR_GID | + (GF_SET_ATTR_MTIME | + GF_SET_ATTR_UID | GF_SET_ATTR_GID | GF_SET_ATTR_MODE), NULL, NULL); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, -- cgit