generic/527: add additional test including a file with a hardlink
PATCH 1/1 generic/527: add additional test including a file with a hardlink
From: Filipe Manana <[email protected]>
Add a similar test to the existing one but with a file that has a hardlink as well. This is motivated by a bug found in btrfs where a fsync on a file that has the old name of another file results in the logging code to hit an infinite loop. The patch that fixes the bug in btrfs has the following subject:
"Btrfs: fix infinite loop during fsync after rename operations"
--- tests/generic/527 | 26 ++++++++++++++++++++++++++ tests/generic/527.out | 4 ++++ 2 files changed, 30 insertions(+)
tests/generic/527 +26 -0
@@ -45,6 +45,12 @@ mkdir $SCRATCH_MNT/testdir echo -n "foo" > $SCRATCH_MNT/testdir/fname1 echo -n "hello" > $SCRATCH_MNT/testdir/fname2 +# For a different variant of the same test but when files have hardlinks too. +mkdir $SCRATCH_MNT/testdir2 +echo -n "foo" > $SCRATCH_MNT/testdir2/zz +ln $SCRATCH_MNT/testdir2/zz $SCRATCH_MNT/testdir2/zz_link +echo -n "hello" > $SCRATCH_MNT/testdir2/a + # Make sure everything done so far is durably persisted. sync
@@ -57,6 +63,21 @@ ln $SCRATCH_MNT/testdir/fname3 $SCRATCH_MNT/testdir/fname2 echo -n "bar" > $SCRATCH_MNT/testdir/fname1 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/fname1 +# A second variant, more complex, that involves files with hardlinks too. + +# The following 3 renames are equivalent to a rename exchange (zz_link to a), but +# without the atomicity which isn't required here. +mv $SCRATCH_MNT/testdir2/a $SCRATCH_MNT/testdir2/tmp +mv $SCRATCH_MNT/testdir2/zz_link $SCRATCH_MNT/testdir2/a +mv $SCRATCH_MNT/testdir2/tmp $SCRATCH_MNT/testdir2/zz_link + +# The following rename and file creation are equivalent to a rename whiteout. +mv $SCRATCH_MNT/testdir2/zz $SCRATCH_MNT/testdir2/a2 +echo -n "bar" > $SCRATCH_MNT/testdir2/zz + +# Fsync of zz should work and produce correct results after a power failure. +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir2/zz + # Simulate a power failure and mount the filesystem to check that all file names # exist and correspond to the correct inodes. _flakey_drop_and_remount
@@ -65,6 +86,11 @@ echo "File fname1 data after power failure: $(cat $SCRATCH_MNT/testdir/fname1)" echo "File fname2 data after power failure: $(cat $SCRATCH_MNT/testdir/fname2)" echo "File fname3 data after power failure: $(cat $SCRATCH_MNT/testdir/fname3)" +echo "File a data after power failure: $(cat $SCRATCH_MNT/testdir2/a)" +echo "File a2 data after power failure: $(cat $SCRATCH_MNT/testdir2/a2)" +echo "File zz data after power failure: $(cat $SCRATCH_MNT/testdir2/zz)" +echo "File zz_link data after power failure: $(cat $SCRATCH_MNT/testdir2/zz_link)" + _unmount_flakey status=0
tests/generic/527.out +4 -0
@@ -2,3 +2,7 @@ QA output created by 527 File fname1 data after power failure: bar File fname2 data after power failure: foo File fname3 data after power failure: foo +File a data after power failure: foo +File a2 data after power failure: foo +File zz data after power failure: bar +File zz_link data after power failure: hello
Signature · 1 line
2.11.0
Quoted 11 lines · On 1/15/20 8:22 AM, [email protected] wrote:
From: Filipe Manana <[email protected]>
Add a similar test to the existing one but with a file that has a hardlink as well. This is motivated by a bug found in btrfs where a fsync on a file that has the old name of another file results in the logging code to hit an infinite loop. The patch that fixes the bug in btrfs has the following subject:
"Btrfs: fix infinite loop during fsync after rename operations"
Signed-off-by Filipe Manana <[email protected]>
What's our policy on adding a new variant to an existing test? I thought we preferred to create a new test for these sort of things? If not then you can add
I have no strong opinions either way, I just know it's come up in the past. Thanks,
Josef
Quoted 10 lines · Josef Bacik
Quoted 8 lines · On 1/15/20 8:22 AM, [email protected] wrote:
From: Filipe Manana <[email protected]>
Add a similar test to the existing one but with a file that has a hardlink as well. This is motivated by a bug found in btrfs where a fsync on a file that has the old name of another file results in the logging code to hit an infinite loop. The patch that fixes the bug in btrfs has the following subject:
Quoted 6 lines
Quoted 3 lines
"Btrfs: fix infinite loop during fsync after rename operations"
Signed-off-by Filipe Manana <[email protected]>What's our policy on adding a new variant to an existing test? I thought we preferred to create a new test for these sort of things? If not then you can add
Usually yes, but since over time there started to be too many fsync related tests, we had a discussion with Dave (Chinner) and others about considering consolidating more tests into the same files. It's not just the number of test files, but more time to run (even if each one adds only 1 or 2 seconds).
That's why I opted here to update generic/527 instead of adding a new test file. Thanks.
Quoted 6 lines
Reviewed-by Josef Bacik <[email protected]>I have no strong opinions either way, I just know it's come up in the past. Thanks,
Josef