xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 252
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 252
6 #
7 # Create an unwritten extent, set up dm-error, try an AIO DIO write, then
8 # make sure we can't read back old disk contents.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.* $testdir $TEST_DIR/moo
23     _dmerror_cleanup
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmerror
30
31 # real QA test starts here
32 _require_scratch
33 _require_dm_target error
34 _require_xfs_io_command "falloc"
35 _require_aiodio "aiocp"
36 AIO_TEST="$here/src/aio-dio-regress/aiocp"
37
38 rm -f $seqres.full
39
40 # Disable the scratch rt device to avoid test failures relating to the rt
41 # bitmap consuming all the free space in our small data device.
42 unset SCRATCH_RTDEV
43
44 fssize=$((196 * 1048576))
45 echo "Format and mount"
46 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
47 _scratch_mkfs_sized $fssize > $seqres.full 2>&1
48 _dmerror_init
49 _dmerror_mount >> $seqres.full 2>&1
50 _dmerror_unmount
51 _dmerror_mount
52
53 testdir=$SCRATCH_MNT/test-$seq
54 mkdir $testdir
55
56 blksz=65536
57 nr=640
58 bufnr=128
59 filesize=$((blksz * nr))
60 bufsize=$((blksz * bufnr))
61 alignment=`_min_dio_alignment $TEST_DEV`
62
63 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 5 / 4))
64
65 echo "Create the original files"
66 $XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
67 _dmerror_unmount
68 _dmerror_mount
69
70 echo "Compare files"
71 md5sum $testdir/file2 | _filter_scratch
72
73 echo "CoW and unmount"
74 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
75 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
76 sync
77 _dmerror_load_error_table
78 $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
79 _dmerror_load_working_table
80 _dmerror_unmount
81 _dmerror_mount
82
83 echo "Compare files"
84 md5sum $testdir/file2 | _filter_scratch
85
86 echo "Check for damage"
87 _dmerror_unmount
88 _dmerror_cleanup
89 _repair_scratch_fs >> $seqres.full
90
91 # success, all done
92 status=0
93 exit