From c539e23023abe743770287439ebe81989a732728 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 9 Dec 2016 07:14:17 +0000 Subject: afr: allow I/O when favorite-child-policy is enabled Problem: Currently, I/O on a split-brained file fails even when the favorite-child-policy is set until the self-heal is complete. Fix: If a valid 'source' is found using the set favorite-child-policy, inspect and reset the afr pending xattrs on the 'sinks' (inside appropriate locks), refresh the inode and then proceed with the read or write transaction. The resetting itself happens in the self-heal code and hence can also happen in the client side background-heal or by the shd's index-heal in addition to the txn code path explained above. When it happens in via heal, we also add checks in undo-pending to not reset the sink xattrs again. > Reviewed-on: http://review.gluster.org/15673 > Tested-by: Pranith Kumar Karampuri > Smoke: Gluster Build System > Reviewed-by: Pranith Kumar Karampuri > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System Change-Id: Ic8c1317720cb26bd114b6fe6af4e58c73b864626 BUG: 1378547 Signed-off-by: Ravishankar N Reported-by: Simon Turcotte-Langevin Reviewed-on: http://review.gluster.org/16091 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Niels de Vos --- .../bugs/replicate/bug-1386188-sbrain-fav-child.t | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/bugs/replicate/bug-1386188-sbrain-fav-child.t (limited to 'tests') diff --git a/tests/bugs/replicate/bug-1386188-sbrain-fav-child.t b/tests/bugs/replicate/bug-1386188-sbrain-fav-child.t new file mode 100644 index 00000000000..d049d95ef9a --- /dev/null +++ b/tests/bugs/replicate/bug-1386188-sbrain-fav-child.t @@ -0,0 +1,82 @@ +#!/bin/bash +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 self-heal-daemon off +TEST $CLI volume set $V0 data-self-heal off +TEST $CLI volume set $V0 entry-self-heal off +TEST $CLI volume set $V0 metadata-self-heal off +TEST $CLI volume start $V0 + +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; +TEST touch $M0/data.txt +TEST touch $M0/mdata.txt + +#Create data and metadata split-brain +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST dd if=/dev/urandom of=$M0/data.txt bs=1024 count=1024 +TEST setfattr -n user.value -v value1 $M0/mdata.txt +TEST $CLI volume start $V0 force +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0 +TEST kill_brick $V0 $H0 $B0/${V0}1 +TEST dd if=/dev/urandom of=$M0/data.txt bs=1024 count=1024 +TEST setfattr -n user.value -v value2 $M0/mdata.txt + +TEST $CLI volume start $V0 force +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1 + +## Check that the file still in split-brain, + ## I/O fails + cat $M0/data.txt > /dev/null + EXPECT "1" echo $? + ## pending xattrs blame each other. + brick0_pending=$(get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0/data.txt) + brick1_pending=$(get_hex_xattr trusted.afr.$V0-client-0 $B0/${V0}1/data.txt) + TEST [ $brick0_pending -ne "000000000000000000000000" ] + TEST [ $brick1_pending -ne "000000000000000000000000" ] + + ## I/O fails + getfattr -n user.value $M0/mdata.txt + EXPECT "1" echo $? + brick0_pending=$(get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0/mdata.txt) + brick1_pending=$(get_hex_xattr trusted.afr.$V0-client-0 $B0/${V0}1/mdata.txt) + TEST [ $brick0_pending -ne "000000000000000000000000" ] + TEST [ $brick1_pending -ne "000000000000000000000000" ] + +## Let us use mtime as fav-child policy. So brick0 will be source. + # Set dirty (data part) on the sink brick to check if it is reset later along with the pending xattr. + TEST setfattr -n trusted.afr.dirty -v 0x000000010000000000000000 $B0/${V0}1/data.txt + # Set dirty (metadata part) on the sink brick to check if it is reset later along with the pending xattr. + TEST setfattr -n trusted.afr.dirty -v 0x000000000000000100000000 $B0/${V0}1/mdata.txt + + TEST $CLI volume set $V0 favorite-child-policy mtime + + # Reading the file should be allowed and sink brick xattrs must be reset. + cat $M0/data.txt > /dev/null + EXPECT "0" echo $? + TEST brick1_pending=$(get_hex_xattr trusted.afr.$V0-client-0 $B0/${V0}1/data.txt) + TEST brick1_dirty=$(get_hex_xattr trusted.afr.dirty $B0/${V0}1/data.txt) + TEST [ $brick1_dirty -eq "000000000000000000000000" ] + TEST [ $brick1_pending -eq "000000000000000000000000" ] + + # Accessing the file should be allowed and sink brick xattrs must be reset. + EXPECT "value2" echo $(getfattr --only-values -n user.value $M0/mdata.txt) + TEST brick1_pending=$(get_hex_xattr trusted.afr.$V0-client-0 $B0/${V0}1/data.txt) + TEST brick1_dirty=$(get_hex_xattr trusted.afr.dirty $B0/${V0}1/data.txt) + TEST [ $brick1_dirty -eq "000000000000000000000000" ] + TEST [ $brick1_pending -eq "000000000000000000000000" ] + +#Enable shd and heal the file. +TEST $CLI volume set $V0 cluster.self-heal-daemon on +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 +TEST $CLI volume heal $V0 +EXPECT 0 get_pending_heal_count $V0 +cleanup; -- cgit From 068e4f345f51438d252b1e330ca7049bd4a67e03 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sat, 7 Jan 2017 14:23:40 +0100 Subject: posix: make sure atime and mtime are set when calling lutimes() When overwriting an existing file with O_TRUNC, the 'atime' was set to 0, meaning the Epoch (01-Jan-1970 UTC). However, the 'mtime' gets updated correcty. In case 'atime' or 'mtime' is not passed in the 'struct iatt', the time values passed to the systemcall are taken from the current values are returned by lstat(). Cherry picked from commit 9bed81ada6f91f998e9abd915b18e3f06557cdcb: > Change-Id: I7021b7161dcd6c9a3e515d98f6d4847533c434b3 > BUG: 1401777 > Reported-by: Eivind Sarto > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/16034 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Raghavendra Bhat > CentOS-regression: Gluster Build System > Reviewed-by: Kaleb KEITHLEY Change-Id: I7021b7161dcd6c9a3e515d98f6d4847533c434b3 BUG: 1411011 Reported-by: Eivind Sarto Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/16356 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kaleb KEITHLEY --- tests/bugs/nfs/zero-atime.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 tests/bugs/nfs/zero-atime.t (limited to 'tests') diff --git a/tests/bugs/nfs/zero-atime.t b/tests/bugs/nfs/zero-atime.t new file mode 100755 index 00000000000..631240a692f --- /dev/null +++ b/tests/bugs/nfs/zero-atime.t @@ -0,0 +1,31 @@ +#!/bin/bash +# +# posix_do_utimes() sets atime and mtime to the values in the passed IATT. If +# not set, these values are 0 and cause a atime/mtime set to the Epoch. +# + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + +cleanup + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume set $V0 nfs.disable false +TEST $CLI volume start $V0 +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available; +TEST mount_nfs $H0:/$V0 $N0 nolock + +# create a file for testing +TEST dd if=/dev/urandom of=$M0/small count=1 bs=1024k + +# timezone in UTC results in atime=0 if not set correctly +TEST TZ=UTC dd if=/dev/urandom of=$M0/small bs=64k count=1 conv=nocreat +TEST [ "$(stat --format=%X $M0/small)" != "0" ] + +TEST rm $M0/small + +cleanup -- cgit