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 _begin_fstest auto quick metadata log
12 # Override the default cleanup function.
18 # Import common functions.
22 # real QA test starts here
24 _require_scratch_nocheck
25 _require_dm_target flakey
30 rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
34 # Btrfs wasn't making sure the directory survived fsync
37 echo "fsync new directory"
39 mkdir $SCRATCH_MNT/bar
40 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
42 _flakey_drop_and_remount
44 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
46 _check_scratch_fs $FLAKEY_DEV
47 [ $? -ne 0 ] && _fatal "fsck failed"
50 # Btrfs was losing a rename into a new directory
53 echo "rename fsync test"
55 touch $SCRATCH_MNT/foo
56 mkdir $SCRATCH_MNT/bar
57 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
58 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
59 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
60 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
62 _flakey_drop_and_remount\
64 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
65 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
67 _check_scratch_fs $FLAKEY_DEV
68 [ $? -ne 0 ] && _fatal "fsck failed"
71 # Btrfs was failing to replay a log when we had a inode with a smaller inode
72 # number that is renamed into a directory with a higher inode number
75 echo "replay rename fsync test"
77 touch $SCRATCH_MNT/foo
78 mkdir $SCRATCH_MNT/bar
79 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
80 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
81 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
83 # This is to force btrfs to relog the entire inode including the ref so
84 # we are sure to try and replay the ref along with the dir_index item
85 setfattr -n user.foo -v blah $SCRATCH_MNT/bar/foo >> $seqres.full 2>&1
87 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
89 _flakey_drop_and_remount
91 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
92 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
96 _scratch_mkfs >> $seqres.full 2>&1
97 _require_metadata_journaling $SCRATCH_DEV
99 # Create a basic flakey device that will never error out