4 # Runs various dir fsync tests to cover fsync'ing directory corner cases.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
29 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # real QA test starts here
45 _require_scratch_nocheck
46 _require_dm_target flakey
47 _require_metadata_journaling $SCRATCH_DEV
54 rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
58 # Btrfs wasn't making sure the directory survived fsync
61 echo "fsync new directory"
63 mkdir $SCRATCH_MNT/bar
64 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
66 _flakey_drop_and_remount
68 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
70 _check_scratch_fs $FLAKEY_DEV
71 [ $? -ne 0 ] && _fatal "fsck failed"
74 # Btrfs was losing a rename into a new directory
77 echo "rename fsync test"
79 touch $SCRATCH_MNT/foo
80 mkdir $SCRATCH_MNT/bar
81 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
82 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
83 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
84 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
86 _flakey_drop_and_remount\
88 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
89 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
91 _check_scratch_fs $FLAKEY_DEV
92 [ $? -ne 0 ] && _fatal "fsck failed"
95 # Btrfs was failing to replay a log when we had a inode with a smaller inode
96 # number that is renamed into a directory with a higher inode number
99 echo "replay rename fsync test"
101 touch $SCRATCH_MNT/foo
102 mkdir $SCRATCH_MNT/bar
103 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
104 mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
105 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
107 # This is to force btrfs to relog the entire inode including the ref so
108 # we are sure to try and replay the ref along with the dir_index item
109 setfattr -n user.foo -v blah $SCRATCH_MNT/bar/foo >> $seqres.full 2>&1
111 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
113 _flakey_drop_and_remount
115 _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
116 _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
120 _scratch_mkfs >> $seqres.full 2>&1
122 # Create a basic flakey device that will never error out