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.
39 _require_dm_target delay
43 echo "Silence is golden."
45 _scratch_mkfs_xfs >> $seqres.full 2>&1
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
57 # remount to clear the buffer cache
61 # introduce a read I/O delay
62 _load_delay_table $DELAY_READ
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
69 $XFS_IO_PROG -c "bmap -v" $SCRATCH_MNT/dir >> $seqres.full 2>&1