2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
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.
12 # Note that this test requires a DEBUG mode kernel.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
27 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
33 # get standard environment, filters and checks
37 # real QA test starts here
39 # Modify as appropriate.
42 _require_xfs_io_error_injection "log_bad_crc"
44 _require_command "$KILLALL_PROG" killall
46 echo "Silence is golden."
48 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
51 sdev=$(_short_dev $SCRATCH_DEV)
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"
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
65 # Verify that we can remount the fs. Log recovery should handle the torn
69 nr_times=$((nr_times - 1))