xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 338
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
4 #
5 # FS QA Test 338
6 #
7 # Test I/O on dm error device.
8 #
9 # Motivated by an ext4 bug that crashes kernel on error path when trying to
10 # update atime.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25         _dmerror_cleanup
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/dmerror
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _require_scratch_nocheck # fs went down with a dirty log, don't check it
39 _require_dm_target error
40 # If SCRATCH_DEV is not a valid block device, FSTYP cannot be mkfs'ed either
41 _require_block_device $SCRATCH_DEV
42
43 echo "Silence is golden"
44
45 _scratch_mkfs >>$seqres.full 2>&1
46 _dmerror_init
47
48 # Use strictatime mount option here to force atime updates, which could help
49 # trigger the NULL pointer dereference on ext4 more easily
50 _dmerror_mount "-o strictatime"
51 _dmerror_load_error_table
52
53 # flush dmerror block device buffers and drop all caches, force reading from
54 # error device
55 blockdev --flushbufs $DMERROR_DEV
56 echo 3 > /proc/sys/vm/drop_caches
57
58 # do some test I/O
59 ls -l $SCRATCH_MNT >>$seqres.full 2>&1
60 $XFS_IO_PROG -fc "pwrite 0 1M" $SCRATCH_MNT/testfile >>$seqres.full 2>&1
61
62 # no panic no hang, success, all done
63 status=0
64 exit