tests: remove udf/101
[xfstests-dev.git] / tests / generic / 418
1 #! /bin/bash
2 # FS QA Test 418
3 #
4 # Test pagecache invalidation in buffer/direct write/read combination.
5 #
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
9 # buffered.
10 #
11 # Regression test for commit c771c14baa33 ("iomap: invalidate page caches
12 # should be after iomap_dio_complete() in direct write")
13 #
14 #-----------------------------------------------------------------------
15 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
16 #
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.
20 #
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.
25 #
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 #-----------------------------------------------------------------------
30 #
31
32 seq=`basename $0`
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43         cd /
44         rm -f $tmp.*
45 }
46
47 # get standard environment, filters and checks
48 . ./common/rc
49 . ./common/filter
50
51 # remove previous $seqres.full before test
52 rm -f $seqres.full
53
54 # real QA test starts here
55 _supported_fs generic
56 _supported_os Linux
57 _require_test
58 _require_odirect
59 _require_block_device $TEST_DEV
60 _require_test_program "dio-invalidate-cache"
61 _require_test_program "feature"
62
63 diotest=$here/src/dio-invalidate-cache
64 testfile=$TEST_DIR/$seq-diotest
65 sectorsize=`blockdev --getss $TEST_DEV`
66 pagesize=`src/feature -s`
67
68 # test case array, test different write/read combinations
69 # -r: use direct read
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
74 t_cases=(
75         "-w"
76         "-wt"
77         "-wp"
78         "-wF"
79         "-r"
80         "-rt"
81         "-rp"
82         "-rF"
83         "-rw"
84         "-rwt"
85         "-rwp"
86         "-rwF"
87 )
88
89 runtest()
90 {
91         local i=0
92         local tc=""
93         local loop=$1
94         shift
95
96         for tc in ${t_cases[*]}; do
97                 echo "diotest $tc $*" >> $seqres.full
98                 i=0
99                 while [ $i -lt $loop ]; do
100                         $diotest $tc $* -f $testfile
101                         if [ $? -ne 0 ]; then
102                                 echo "diotest $tc $* failed at loop $i" | \
103                                         tee -a $seqres.full
104                                 break
105                         fi
106                         let i=i+1
107                 done
108         done
109 }
110
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))
117 done
118 echo "Silence is golden"
119
120 # success, all done
121 status=0
122 exit