generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 427
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 427
6 #
7 # Try to trigger a race of free eofblocks and file extending dio writes.
8 # A known bug of XFS has been fixed by "e4229d6 xfs: fix eofblocks race
9 # with file extending async dio writes"
10 #
11 . ./common/preamble
12 _begin_fstest auto quick aio rw
13
14 # Import common functions.
15 . ./common/filter
16
17 # real QA test starts here
18
19 # Modify as appropriate.
20 _supported_fs generic
21 _require_scratch
22 _require_test_program "feature"
23 _require_aiodio aio-dio-eof-race
24
25 # limit the filesystem size, to save the time of filling filesystem
26 _scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
27 _scratch_mount
28
29 # try to write more bytes than filesystem size to fill the filesystem,
30 # then remove all these data. If we still can find these stale data in
31 # a file' eofblock, then it's a bug
32 $XFS_IO_PROG -f -c "pwrite -S 0x55 0 $((256 * 1024 * 1024 * 2))" \
33              $SCRATCH_MNT/fillfs-$seq 2>/dev/null
34 rm -f $SCRATCH_MNT/fillfs-$seq
35
36 # open & close the file frequently, to trigger xfs_free_eofblocks
37 while true; do
38         $XFS_IO_PROG -f -c open $SCRATCH_MNT/tst-aio-dio-eof-race.$seq \
39                 >/dev/null 2>&1
40 done &
41 open_close_pid=$!
42
43 nr_cpu=`$here/src/feature -o`
44 fsize=$((nr_cpu * 10))
45 if [ $fsize -gt 200 ]; then
46         fsize=200
47 fi
48 # start a background aio writer, which does several extending loops
49 # internally and check data integrality
50 $AIO_TEST -s $fsize -b 65536 $SCRATCH_MNT/tst-aio-dio-eof-race.$seq
51 status=$?
52
53 kill $open_close_pid
54 wait $open_close_pid
55 exit