2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Oracle, Inc. All Rights Reserved.
7 # Simulate a buffer use after free race in XFS log recovery. The race triggers
8 # on I/O failures during log recovery. Note that this test is dangerous as it
9 # causes BUG() errors or a panic.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
24 $KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
25 _scratch_unmount > /dev/null 2>&1
28 # get standard environment, filters and checks
32 # Modify as appropriate.
36 _require_dm_target flakey
37 _require_xfs_sysfs debug/log_recovery_delay
38 _require_command "$KILLALL_PROG" killall
40 echo "Silence is golden."
42 _scratch_mkfs_xfs >/dev/null 2>&1
45 # Start a workload and shutdown the fs. The subsequent mount will require log
47 $FSSTRESS_PROG -n 9999 -p 2 -w -d $SCRATCH_MNT > /dev/null 2>&1 &
50 $KILLALL_PROG -q $FSSTRESS_PROG
54 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
56 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
57 FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 5 180"
58 _load_flakey_table $FLAKEY_ALLOW_WRITES
60 # Set a 10s log recovery delay and mount the flakey device. This should allow
61 # initial writes to proceed (e.g., stale log block reset) and then let the
62 # flakey uptime timer expire such that I/Os will fail by the time log recovery
64 echo 10 > /sys/fs/xfs/debug/log_recovery_delay
66 # The mount should fail due to dm-flakey. Note that this is dangerous on kernels
67 # without the xfs_buf log recovery race fixes.
68 _mount_flakey > /dev/null 2>&1
70 echo 0 > /sys/fs/xfs/debug/log_recovery_delay