4 # Simulate a buffer use after free race in XFS log recovery. The race triggers
5 # on I/O failures during log recovery. Note that this test is dangerous as it
6 # causes BUG() errors or a panic.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Oracle, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
39 killall -9 $FSSTRESS_PROG > /dev/null 2>&1
40 _scratch_unmount > /dev/null 2>&1
43 # get standard environment, filters and checks
47 # Modify as appropriate.
53 _require_xfs_sysfs debug/log_recovery_delay
55 echo "Silence is golden."
57 _scratch_mkfs_xfs >/dev/null 2>&1
60 # Start a workload and shutdown the fs. The subsequent mount will require log
62 $FSSTRESS_PROG -n 9999 -p 2 -w -d $SCRATCH_MNT > /dev/null 2>&1 &
64 src/godown -f $SCRATCH_MNT
65 killall -q $FSSTRESS_PROG
69 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
71 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
72 FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 5 180"
73 _load_flakey_table $FLAKEY_ALLOW_WRITES
75 # Set a 10s log recovery delay and mount the flakey device. This should allow
76 # initial writes to proceed (e.g., stale log block reset) and then let the
77 # flakey uptime timer expire such that I/Os will fail by the time log recovery
79 echo 10 > /sys/fs/xfs/debug/log_recovery_delay
81 # The mount should fail due to dm-flakey. Note that this is dangerous on kernels
82 # without the xfs_buf log recovery race fixes.
83 _mount_flakey > /dev/null 2>&1
85 echo 0 > /sys/fs/xfs/debug/log_recovery_delay