4 # Test pagecache invalidation in buffer/direct write/read combination.
6 # Fork N children, each child writes to and reads from its own region of the
7 # same test file, and check if what it reads is what it writes. The test region
8 # is determined by N * blksz. Write and read operation can be either direct or
11 # Regression test for commit c771c14baa33 ("iomap: invalidate page caches
12 # should be after iomap_dio_complete() in direct write")
14 #-----------------------------------------------------------------------
15 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
17 # This program is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License as
19 # published by the Free Software Foundation.
21 # This program is distributed in the hope that it would be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write the Free Software Foundation,
28 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #-----------------------------------------------------------------------
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
38 status=1 # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
47 # get standard environment, filters and checks
51 # remove previous $seqres.full before test
54 # real QA test starts here
59 _require_block_device $TEST_DEV
60 _require_test_program "dio-invalidate-cache"
61 _require_test_program "feature"
63 diotest=$here/src/dio-invalidate-cache
64 testfile=$TEST_DIR/$seq-diotest
65 sectorsize=`blockdev --getss $TEST_DEV`
66 pagesize=`src/feature -s`
68 # test case array, test different write/read combinations
70 # -w: use direct write
71 # -t: truncate file to final size before test, i.e. write to hole
72 # -p: fallocate whole file before test, i.e. write to allocated but unwritten extents
73 # -F: fulfill whole file before test, i.e. write to allocated & written extents
96 for tc in ${t_cases[*]}; do
97 echo "diotest $tc $*" >> $seqres.full
99 while [ $i -lt $loop ]; do
100 $diotest $tc $* -f $testfile
101 if [ $? -ne 0 ]; then
102 echo "diotest $tc $* failed at loop $i" | \
111 while [ $sectorsize -le $((pagesize * 2)) ]; do
112 # reproducer for the original bug
113 runtest $((10 * LOAD_FACTOR)) -b $sectorsize -n 3 -i 1
114 # try more processes and iterations
115 runtest $((5 * LOAD_FACTOR)) -b $sectorsize -n 8 -i 4
116 sectorsize=$((sectorsize * 2))
118 echo "Silence is golden"