4 # Regression test for commit:
5 # 04197b3 ("xfs: don't BUG() on mixed direct and mapped I/O")
7 # This case tests a race between a direct I/O read and a
8 # mapped write to a hole in a file. On xfs filesystem, it
9 # will trigger a BUG_ON().
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2017 Fujitsu. All Rights Reserved.
13 # Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment and checks
46 # real QA test starts here
49 _require_xfs_io_command "truncate"
50 _require_xfs_io_command "fpunch"
55 _scratch_mkfs > $seqres.full 2>&1
56 _scratch_mount >> $seqres.full 2>&1
60 # create a test file with a hole
61 $XFS_IO_PROG -f -c "truncate $((filesz * 2))" $SCRATCH_MNT/file >> $seqres.full
63 # run a background dio read to a hole in a loop
64 for i in `seq 0 999`; do
65 $XFS_IO_PROG -d -c "pread 0 $filesz" $SCRATCH_MNT/file > /dev/null 2>&1
70 # run mapped write to the same hole as dio read
71 # loop until background dio read exits
72 while kill -s 0 $dread_pid >/dev/null 2>&1; do
73 $XFS_IO_PROG -c "mmap 0 $filesz" -c "mwrite 0 $filesz" $SCRATCH_MNT/file \
75 $XFS_IO_PROG -c "fpunch 0 $filesz" $SCRATCH_MNT/file > /dev/null
78 wait $dread_pid > /dev/null 2>&1
80 echo "Silence is golden"
82 # check dmesg, filtering out expected XFS warnings about mixed mmap/dio
83 # and umount first in case umount triggers warnings
85 if [ "$FSTYP" == "xfs" ]; then
86 _check_dmesg _filter_xfs_dmesg