xfs/141: run for longer with TIME_FACTOR
[xfstests-dev.git] / tests / xfs / 141
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 141
6 #
7 # Use the XFS log record CRC error injection mechanism to test torn writes to
8 # the log. The error injection mechanism writes an invalid CRC and shuts down
9 # the filesystem. The test verifies that a subsequent remount recovers the log
10 # and that the filesystem is consistent.
11 #
12 # Note that this test requires a DEBUG mode kernel.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
28         wait > /dev/null 2>&1
29 }
30
31 rm -f $seqres.full
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/inject
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs xfs
41 _supported_os Linux
42 _require_xfs_io_error_injection "log_bad_crc"
43 _require_scratch
44 _require_command "$KILLALL_PROG" killall
45
46 echo "Silence is golden."
47
48 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
49 _scratch_mount
50
51 sdev=$(_short_dev $SCRATCH_DEV)
52
53 nr_times=$((TIME_FACTOR * 5))
54 while [ $nr_times -gt 0 ]; do
55         # Enable error injection. Use a random bad crc factor up to 100
56         # (increase this value to run fsstress longer).
57         factor=$((RANDOM % 100 + 1))
58         echo iteration $i log_badcrc_factor: $factor >> $seqres.full 2>&1
59         _scratch_inject_error "log_bad_crc" "$factor"
60
61         # Run fsstress until the filesystem shuts down. It will shut down
62         # automatically when error injection triggers.
63         $FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 999999 >> $seqres.full 2>&1
64
65         # Verify that we can remount the fs. Log recovery should handle the torn
66         # write.
67         _scratch_unmount
68         _scratch_mount
69         nr_times=$((nr_times - 1))
70 done
71
72 # success, all done
73 status=0
74 exit