2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
7 # Runs various rename fsync tests to cover some rename fsync corner cases.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
14 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
22 # get standard environment, filters and checks
27 # real QA test starts here
30 _require_scratch_nocheck
31 _require_dm_target flakey
38 rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
42 # Btrfs wasn't making sure the new file after rename survived the fsync
45 echo "fsync rename test"
47 $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $SCRATCH_MNT/foo \
49 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
50 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
51 md5sum $SCRATCH_MNT/bar | _filter_scratch
53 _flakey_drop_and_remount
55 md5sum $SCRATCH_MNT/bar | _filter_scratch
57 _check_scratch_fs $FLAKEY_DEV
58 [ $? -ne 0 ] && _fatal "fsck failed"
61 # Btrfs was dropping some of the modified extents in between fsyncs if we
63 _write_after_fsync_rename_test()
65 echo "fsync rename test"
67 $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" -c "pwrite 2M 1M" \
68 -c "sync_range -b 2M 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1
69 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
70 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
71 md5sum $SCRATCH_MNT/bar | _filter_scratch
73 _flakey_drop_and_remount
75 md5sum $SCRATCH_MNT/bar | _filter_scratch
79 _scratch_mkfs >> $seqres.full 2>&1
80 _require_metadata_journaling $SCRATCH_DEV
82 # Create a basic flakey device that will never error out
87 _write_after_fsync_rename_test