4 # Run various fsync tests with dm flakey in freeze() mode and non freeze()
5 # mode. The idea is that we do random writes and randomly fsync and verify that
6 # after a fsync() followed by a freeze()+failure or just failure that the file
7 # is correct. We remount the file system after the failure so that the file
8 # system can do whatever cleanup it needs to and md5sum the file to make sure
9 # it matches hat it was before the failure. We also fsck to make sure the file
10 # system is consistent.
12 # The fsync tester just random writes into prealloc or not, and then fsync()s
13 # randomly or sync()'s randomly and then fsync()'s before exit. There are a few
14 # tests that were handcrafted to reproduce bugs in btrfs, so it's also a
15 # regression test of sorts.
17 #-----------------------------------------------------------------------
18 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #-----------------------------------------------------------------------
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
40 status=1 # failure is the default!
46 trap "_cleanup; exit \$status" 0 1 2 3 15
48 # get standard environment, filters and checks
53 # real QA test starts here
57 _require_scratch_nocheck
58 _require_dm_target flakey
59 _require_metadata_journaling $SCRATCH_DEV
61 # xfs_io is not required for this test, but it's the best way to verify
62 # the test system supports fallocate() for allocation
63 _require_xfs_io_command "falloc"
65 _require_test_program "fsync-tester"
69 testfile=$SCRATCH_MNT/$seq.fsync
73 # _run_test <testnum> <0 - buffered | 1 - O_DIRECT>
77 [ $2 -eq 1 ] && direct_opt="-d"
79 $here/src/fsync-tester -s $SEED -t $test_num $direct_opt $testfile
80 [ $? -ne 0 ] && _fatal "fsync tester exited abnormally"
82 _md5_checksum $testfile
83 _load_flakey_table $FLAKEY_DROP_WRITES $lockfs
86 #Ok mount so that any recovery that needs to happen is done
87 _load_flakey_table $FLAKEY_ALLOW_WRITES
89 _md5_checksum $testfile
91 #Unmount and fsck to make sure we got a valid fs after replay
93 _check_scratch_fs $FLAKEY_DEV
94 [ $? -ne 0 ] && _fatal "fsck failed"
99 _scratch_mkfs >> $seqres.full 2>&1
101 # Create a basic flakey device that will never error out
108 for i in $(seq 1 20); do
111 echo "Running test $i buffered, normal suspend"
112 _run_test $i $buffered
113 echo "Running test $i direct, normal suspend"
117 echo "Running test $i buffered, nolockfs"
118 _run_test $i $buffered
119 echo "Running test $i direct, nolockfs"