2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
7 # Runs various dir fsync tests to cover fsync'ing directory 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 directory survived fsync
45 echo "fsync new directory"
47 mkdir $SCRATCH_MNT/bar
48 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
50 _flakey_drop_and_remount
52 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
54 _check_scratch_fs $FLAKEY_DEV
55 [ $? -ne 0 ] && _fatal "fsck failed"
58 # Btrfs was losing a rename into a new directory
61 echo "rename fsync test"
63 touch $SCRATCH_MNT/foo
64 mkdir $SCRATCH_MNT/bar
65 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
66 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
67 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
68 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
70 _flakey_drop_and_remount\
72 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
73 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
75 _check_scratch_fs $FLAKEY_DEV
76 [ $? -ne 0 ] && _fatal "fsck failed"
79 # Btrfs was failing to replay a log when we had a inode with a smaller inode
80 # number that is renamed into a directory with a higher inode number
83 echo "replay rename fsync test"
85 touch $SCRATCH_MNT/foo
86 mkdir $SCRATCH_MNT/bar
87 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
88 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
89 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
91 # This is to force btrfs to relog the entire inode including the ref so
92 # we are sure to try and replay the ref along with the dir_index item
93 setfattr -n user.foo -v blah $SCRATCH_MNT/bar/foo >> $seqres.full 2>&1
95 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
97 _flakey_drop_and_remount
99 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
100 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
104 _scratch_mkfs >> $seqres.full 2>&1
105 _require_metadata_journaling $SCRATCH_DEV
107 # Create a basic flakey device that will never error out