xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 311
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 311
6 #
7 # Test to reproduce an XFS unmount crash due to races with directory readahead.
8 # XFS had a bug in which unmount would proceed with a readahead I/O in flight.
9 # If the unmount deconstructed the log by the time I/O completion occurs,
10 # certain metadata read verifier checks could access invalid memory and cause a
11 # panic.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26         _scratch_unmount > /dev/null 2>&1
27         _cleanup_delay > /dev/null 2>&1
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/dmdelay
33
34 # Modify as appropriate.
35 _supported_fs xfs
36 _supported_os Linux
37
38 _require_scratch
39 _require_dm_target delay
40
41 rm -f $seqres.full
42
43 echo "Silence is golden."
44
45 _scratch_mkfs_xfs >> $seqres.full 2>&1
46
47 _init_delay
48 _mount_delay
49
50 # insert entries to grow the directory to at least one extent, which is what
51 # triggers readahead on dir open
52 mkdir $SCRATCH_MNT/dir
53 for i in $(seq 0 999); do
54         echo > $SCRATCH_MNT/dir/$i
55 done
56
57 # remount to clear the buffer cache
58 _unmount_delay
59 _mount_delay
60
61 # introduce a read I/O delay
62 _load_delay_table $DELAY_READ
63
64 # Map the directory and immediately unmount. This should invoke an asynchronous
65 # readahead on the first block of the directory. The readahead is delayed by
66 # dm-delay. If the unmount doesn't properly wait for the readahead completion,
67 # the read verifier can run after core data structures have been freed and lead
68 # to a crash/panic.
69 $XFS_IO_PROG -c "bmap -v" $SCRATCH_MNT/dir >> $seqres.full 2>&1
70 _unmount_delay
71
72 _cleanup_delay
73
74 # success, all done
75 status=0
76 exit