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
43 _require_block_device $TEST_DEV
44 _require_test_program "dio-invalidate-cache"
45 _require_test_program "feature"
47 diotest=$here/src/dio-invalidate-cache
48 testfile=$TEST_DIR/$seq-diotest
49 sectorsize=`blockdev --getss $TEST_DEV`
50 pagesize=`$here/src/feature -s`
52 # test case array, test different write/read combinations
54 # -w: use direct write
55 # -t: truncate file to final size before test, i.e. write to hole
56 # -p: fallocate whole file before test, i.e. write to allocated but unwritten extents
57 # -F: fulfill whole file before test, i.e. write to allocated & written extents
80 for tc in ${t_cases[*]}; do
81 echo "diotest $tc $*" >> $seqres.full
83 while [ $i -lt $loop ]; do
84 $diotest $tc $* -f $testfile
86 echo "diotest $tc $* failed at loop $i" | \
95 while [ $sectorsize -le $((pagesize * 2)) ]; do
96 # reproducer for the original bug
97 runtest $((10 * LOAD_FACTOR)) -b $sectorsize -n 3 -i 1
98 # try more processes and iterations
99 runtest $((5 * LOAD_FACTOR)) -b $sectorsize -n 8 -i 4
100 sectorsize=$((sectorsize * 2))
102 echo "Silence is golden"