2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
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
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
26 _scratch_unmount > /dev/null 2>&1
27 _cleanup_delay > /dev/null 2>&1
30 # get standard environment, filters and checks
34 # Modify as appropriate.
38 _require_dm_target delay
42 echo "Silence is golden."
44 _scratch_mkfs_xfs >> $seqres.full 2>&1
49 # insert entries to grow the directory to at least one extent, which is what
50 # triggers readahead on dir open
51 mkdir $SCRATCH_MNT/dir
52 for i in $(seq 0 999); do
53 echo > $SCRATCH_MNT/dir/$i
56 # remount to clear the buffer cache
60 # introduce a read I/O delay
61 _load_delay_table $DELAY_READ
63 # Map the directory and immediately unmount. This should invoke an asynchronous
64 # readahead on the first block of the directory. The readahead is delayed by
65 # dm-delay. If the unmount doesn't properly wait for the readahead completion,
66 # the read verifier can run after core data structures have been freed and lead
68 $XFS_IO_PROG -c "bmap -v" $SCRATCH_MNT/dir >> $seqres.full 2>&1