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")
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
23 status=1 # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # get standard environment, filters and checks
36 # remove previous $seqres.full before test
39 # real QA test starts here
44 _require_block_device $TEST_DEV
45 _require_test_program "dio-invalidate-cache"
46 _require_test_program "feature"
48 diotest=$here/src/dio-invalidate-cache
49 testfile=$TEST_DIR/$seq-diotest
50 sectorsize=`blockdev --getss $TEST_DEV`
51 pagesize=`$here/src/feature -s`
53 # test case array, test different write/read combinations
55 # -w: use direct write
56 # -t: truncate file to final size before test, i.e. write to hole
57 # -p: fallocate whole file before test, i.e. write to allocated but unwritten extents
58 # -F: fulfill whole file before test, i.e. write to allocated & written extents
81 for tc in ${t_cases[*]}; do
82 echo "diotest $tc $*" >> $seqres.full
84 while [ $i -lt $loop ]; do
85 $diotest $tc $* -f $testfile
87 echo "diotest $tc $* failed at loop $i" | \
96 while [ $sectorsize -le $((pagesize * 2)) ]; do
97 # reproducer for the original bug
98 runtest $((10 * LOAD_FACTOR)) -b $sectorsize -n 3 -i 1
99 # try more processes and iterations
100 runtest $((5 * LOAD_FACTOR)) -b $sectorsize -n 8 -i 4
101 sectorsize=$((sectorsize * 2))
103 echo "Silence is golden"