2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Fujitsu. All Rights Reserved.
7 # Regression test for commit:
8 # 04197b3 ("xfs: don't BUG() on mixed direct and mapped I/O")
10 # This case tests a race between a direct I/O read and a
11 # mapped write to a hole in a file. On xfs filesystem, it
12 # will trigger a BUG_ON().
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment and checks
32 # real QA test starts here
34 _require_xfs_io_command "truncate"
35 _require_xfs_io_command "fpunch"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
45 # create a test file with a hole
46 $XFS_IO_PROG -f -c "truncate $((filesz * 2))" $SCRATCH_MNT/file >> $seqres.full
48 # run a background dio read to a hole in a loop
49 for i in `seq 0 999`; do
50 $XFS_IO_PROG -d -c "pread 0 $filesz" $SCRATCH_MNT/file > /dev/null 2>&1
55 # run mapped write to the same hole as dio read
56 # loop until background dio read exits
57 while kill -s 0 $dread_pid >/dev/null 2>&1; do
58 $XFS_IO_PROG -c "mmap 0 $filesz" -c "mwrite 0 $filesz" $SCRATCH_MNT/file \
60 $XFS_IO_PROG -c "fpunch 0 $filesz" $SCRATCH_MNT/file > /dev/null
63 wait $dread_pid > /dev/null 2>&1
65 echo "Silence is golden"
67 # check dmesg, filtering out expected warnings about mixed mmap/dio
68 # and umount first in case umount triggers warnings
70 _check_dmesg _filter_aiodio_dmesg