xfs/029: filter out "extended-header: cycle: 1" from output
[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 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24         $KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
25         _scratch_unmount > /dev/null 2>&1
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/dmflakey
31
32 # Modify as appropriate.
33 _supported_fs xfs
34 _supported_os Linux
35
36 _require_scratch
37 _require_dm_target flakey
38 _require_xfs_sysfs debug/log_recovery_delay
39 _require_command "$KILLALL_PROG" killall
40
41 echo "Silence is golden."
42
43 _scratch_mkfs_xfs >/dev/null 2>&1
44 _scratch_mount
45
46 # Start a workload and shutdown the fs. The subsequent mount will require log
47 # recovery.
48 $FSSTRESS_PROG -n 9999 -p 2 -w -d $SCRATCH_MNT > /dev/null 2>&1 &
49 sleep 5
50 _scratch_shutdown -f
51 $KILLALL_PROG -q $FSSTRESS_PROG
52 wait
53 _scratch_unmount
54
55 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
56 _init_flakey
57 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
58 FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 5 180"
59 _load_flakey_table $FLAKEY_ALLOW_WRITES
60
61 # Set a 10s log recovery delay and mount the flakey device. This should allow
62 # initial writes to proceed (e.g., stale log block reset) and then let the
63 # flakey uptime timer expire such that I/Os will fail by the time log recovery
64 # starts.
65 echo 10 > /sys/fs/xfs/debug/log_recovery_delay
66
67 # The mount should fail due to dm-flakey. Note that this is dangerous on kernels
68 # without the xfs_buf log recovery race fixes.
69 _mount_flakey > /dev/null 2>&1
70
71 echo 0 > /sys/fs/xfs/debug/log_recovery_delay
72
73 _cleanup_flakey
74
75 # replay the log
76 _scratch_mount
77 _scratch_unmount
78
79 # success, all done
80 status=0
81 exit