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
60 # xfs_io is not required for this test, but it's the best way to verify
61 # the test system supports fallocate() for allocation
62 _require_xfs_io_command "falloc"
64 [ -x $here/src/fsync-tester ] || _notrun "fsync-tester not built"
68 testfile=$SCRATCH_MNT/$seq.fsync
72 # _run_test <testnum> <0 - buffered | 1 - O_DIRECT>
76 [ $2 -eq 1 ] && direct_opt="-d"
78 $here/src/fsync-tester -s $SEED -t $test_num $direct_opt $testfile
79 [ $? -ne 0 ] && _fatal "fsync tester exited abnormally"
81 _md5_checksum $testfile
82 _load_flakey_table $FLAKEY_DROP_WRITES $lockfs
85 #Ok mount so that any recovery that needs to happen is done
86 _load_flakey_table $FLAKEY_ALLOW_WRITES
88 _md5_checksum $testfile
90 #Unmount and fsck to make sure we got a valid fs after replay
92 _check_scratch_fs $FLAKEY_DEV
93 [ $? -ne 0 ] && _fatal "fsck failed"
98 _scratch_mkfs >> $seqres.full 2>&1
100 # Create a basic flakey device that will never error out
107 for i in $(seq 1 20); do
110 echo "Running test $i buffered, normal suspend"
111 _run_test $i $buffered
112 echo "Running test $i direct, normal suspend"
116 echo "Running test $i buffered, nolockfs"
117 _run_test $i $buffered
118 echo "Running test $i direct, nolockfs"