2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
7 # Test pagecache invalidation in buffer/direct write/read combination.
9 # Fork N children, each child writes to and reads from its own region of the
10 # same test file, and check if what it reads is what it writes. The test region
11 # is determined by N * blksz. Write and read operation can be either direct or
14 # Regression test for commit c771c14baa33 ("iomap: invalidate page caches
15 # should be after iomap_dio_complete() in direct write")
20 # Import common functions.
23 # real QA test starts here
27 _require_block_device $TEST_DEV
28 _require_test_program "dio-invalidate-cache"
29 _require_test_program "feature"
31 diotest=$here/src/dio-invalidate-cache
32 testfile=$TEST_DIR/$seq-diotest
33 sectorsize=`blockdev --getss $TEST_DEV`
34 pagesize=`$here/src/feature -s`
36 # test case array, test different write/read combinations
38 # -w: use direct write
39 # -t: truncate file to final size before test, i.e. write to hole
40 # -p: fallocate whole file before test, i.e. write to allocated but unwritten extents
41 # -F: fulfill whole file before test, i.e. write to allocated & written extents
64 for tc in ${t_cases[*]}; do
65 echo "diotest $tc $*" >> $seqres.full
67 while [ $i -lt $loop ]; do
68 $diotest $tc $* -f $testfile
70 echo "diotest $tc $* failed at loop $i" | \
79 while [ $sectorsize -le $((pagesize * 2)) ]; do
80 # reproducer for the original bug
81 runtest $((10 * LOAD_FACTOR)) -b $sectorsize -n 3 -i 1
82 # try more processes and iterations
83 runtest $((5 * LOAD_FACTOR)) -b $sectorsize -n 8 -i 4
84 sectorsize=$((sectorsize * 2))
86 echo "Silence is golden"