summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Blomdell <anders.blomdell@control.lth.se>2014-07-29 17:11:20 +0200
committerAnand Avati <avati@redhat.com>2014-07-31 09:07:59 -0700
commita278c2aecedfbe17e2749109d73b292ca25ff439 (patch)
tree641fffd317549e0f1da0c096b4c00b2c8d163fdb
parent93a4558dddbea78a51171b2bf92e37da3ffb40dd (diff)
Symlink mtime changes when rebalancing
Added mtime preservation for special files during rebalance. Change-Id: If04921d4d66853fde8b4d8a3ab748790864f8f42 BUG: 1122443 Signed-off-by: Anders Blomdell <anders.blomdell@control.lth.se> Reviewed-on: http://review.gluster.org/8383 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--tests/bugs/bug-1122443.t59
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c3
2 files changed, 61 insertions, 1 deletions
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,