fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 051
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 051
6 #
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.
10 #
11 . ./common/preamble
12 _begin_fstest shutdown auto log metadata
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         cd /
18         rm -f $tmp.*
19         $KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
20         _scratch_unmount > /dev/null 2>&1
21 }
22
23 # Import common functions.
24 . ./common/dmflakey
25
26 # Modify as appropriate.
27 _supported_fs xfs
28
29 _require_scratch
30 _require_dm_target flakey
31 _require_xfs_sysfs debug/log_recovery_delay
32 _require_command "$KILLALL_PROG" killall
33
34 echo "Silence is golden."
35
36 _scratch_mkfs_xfs >/dev/null 2>&1
37 _scratch_mount
38
39 # Start a workload and shutdown the fs. The subsequent mount will require log
40 # recovery.
41 $FSSTRESS_PROG -n 9999 -p 2 -w -d $SCRATCH_MNT > /dev/null 2>&1 &
42 sleep 5
43 _scratch_shutdown -f
44 $KILLALL_PROG -q $FSSTRESS_PROG
45 wait
46 _scratch_unmount
47
48 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
49 _init_flakey
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
53
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
57 # starts.
58 echo 10 > /sys/fs/xfs/debug/log_recovery_delay
59
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
63
64 echo 0 > /sys/fs/xfs/debug/log_recovery_delay
65
66 _cleanup_flakey
67
68 # replay the log
69 _scratch_mount
70 _scratch_unmount
71
72 # success, all done
73 status=0
74 exit