4 # Use the XFS log record CRC error injection mechanism to test torn writes to
5 # the log. The error injection mechanism writes an invalid CRC and shuts down
6 # the filesystem. The test verifies that a subsequent remount recovers the log
7 # and that the filesystem is consistent.
9 # Note that this test requires a DEBUG mode kernel.
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
42 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
48 # get standard environment, filters and checks
52 # real QA test starts here
54 # Modify as appropriate.
57 _require_xfs_io_error_injection "log_bad_crc"
59 _require_command "$KILLALL_PROG" killall
61 echo "Silence is golden."
63 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
66 sdev=$(_short_dev $SCRATCH_DEV)
68 for i in $(seq 1 5); do
69 # Enable error injection. Use a random bad crc factor up to 100
70 # (increase this value to run fsstress longer).
71 factor=$((RANDOM % 100 + 1))
72 echo iteration $i log_badcrc_factor: $factor >> $seqres.full 2>&1
73 _scratch_inject_error "log_bad_crc" "$factor"
75 # Run fsstress until the filesystem shuts down. It will shut down
76 # automatically when error injection triggers.
77 $FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 999999 >> $seqres.full 2>&1
79 # Verify that we can remount the fs. Log recovery should handle the torn
82 _scratch_mount || _fail "failed to mount"