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 _begin_fstest shutdown auto log metadata
14 # Override the default cleanup function.
19 $KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
20 _scratch_unmount > /dev/null 2>&1
23 # Import common functions.
26 # Modify as appropriate.
30 _require_dm_target flakey
31 _require_xfs_sysfs debug/log_recovery_delay
32 _require_command "$KILLALL_PROG" killall
34 echo "Silence is golden."
36 _scratch_mkfs_xfs >/dev/null 2>&1
39 # Start a workload and shutdown the fs. The subsequent mount will require log
41 $FSSTRESS_PROG -n 9999 -p 2 -w -d $SCRATCH_MNT > /dev/null 2>&1 &
44 $KILLALL_PROG -q $FSSTRESS_PROG
48 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
50 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
51 FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 5 180"
52 _load_flakey_table $FLAKEY_ALLOW_WRITES
54 # Set a 10s log recovery delay and mount the flakey device. This should allow
55 # initial writes to proceed (e.g., stale log block reset) and then let the
56 # flakey uptime timer expire such that I/Os will fail by the time log recovery
58 echo 10 > /sys/fs/xfs/debug/log_recovery_delay
60 # The mount should fail due to dm-flakey. Note that this is dangerous on kernels
61 # without the xfs_buf log recovery race fixes.
62 _mount_flakey > /dev/null 2>&1
64 echo 0 > /sys/fs/xfs/debug/log_recovery_delay