]>
Commit | Line | Data |
---|---|---|
9e1cb96d KW |
1 | #!/bin/bash |
2 | # | |
3 | # Test concurrent pread/pwrite | |
4 | # | |
5 | # Copyright (C) 2014 Red Hat, Inc. | |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 2 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | # | |
20 | ||
21 | # creator | |
22 | [email protected] | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
27 | here=`pwd` | |
9e1cb96d KW |
28 | status=1 # failure is the default! |
29 | ||
30 | _cleanup() | |
31 | { | |
32 | _cleanup_test_img | |
33 | } | |
34 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
35 | ||
36 | # get standard environment, filters and checks | |
37 | . ./common.rc | |
38 | . ./common.filter | |
39 | ||
f5106206 | 40 | _supported_fmt raw |
9e1cb96d KW |
41 | _supported_proto generic |
42 | _supported_os Linux | |
43 | ||
44 | CLUSTER_SIZE=4k | |
45 | size=128M | |
46 | ||
47 | _make_test_img $size | |
48 | ||
49 | echo | |
50 | echo "== Some concurrent requests involving RMW ==" | |
51 | ||
52 | function test_io() | |
53 | { | |
8f9e835f | 54 | echo "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG" |
9e1cb96d KW |
55 | # A simple RMW request |
56 | cat <<EOF | |
57 | aio_write -P 10 0x200 0x200 | |
58 | aio_flush | |
59 | EOF | |
60 | ||
61 | # Sequential RMW requests on the same physical sector | |
62 | off=0x1000 | |
63 | for ev in "head" "after_head" "tail" "after_tail"; do | |
64 | cat <<EOF | |
5be5b776 | 65 | break pwritev_rmw_$ev A |
9e1cb96d KW |
66 | aio_write -P 10 $((off + 0x200)) 0x200 |
67 | wait_break A | |
68 | aio_write -P 11 $((off + 0x400)) 0x200 | |
69 | sleep 100 | |
70 | resume A | |
71 | aio_flush | |
72 | EOF | |
73 | off=$((off + 0x1000)) | |
74 | done | |
75 | ||
76 | # Chained dependencies | |
77 | cat <<EOF | |
5be5b776 | 78 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
79 | aio_write -P 10 0x5000 0x200 |
80 | wait_break A | |
81 | aio_write -P 11 0x5200 0x200 | |
82 | aio_write -P 12 0x5400 0x200 | |
83 | aio_write -P 13 0x5600 0x200 | |
84 | aio_write -P 14 0x5800 0x200 | |
85 | aio_write -P 15 0x5a00 0x200 | |
86 | aio_write -P 16 0x5c00 0x200 | |
87 | aio_write -P 17 0x5e00 0x200 | |
88 | sleep 100 | |
89 | resume A | |
90 | aio_flush | |
91 | EOF | |
92 | ||
93 | # Overlapping multiple requests | |
94 | cat <<EOF | |
5be5b776 | 95 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
96 | aio_write -P 10 0x6000 0x200 |
97 | wait_break A | |
5be5b776 | 98 | break pwritev_rmw_after_head B |
9e1cb96d KW |
99 | aio_write -P 10 0x7e00 0x200 |
100 | wait_break B | |
101 | aio_write -P 11 0x6800 0x1000 | |
102 | resume A | |
103 | sleep 100 | |
104 | resume B | |
105 | aio_flush | |
106 | EOF | |
107 | ||
108 | cat <<EOF | |
5be5b776 | 109 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
110 | aio_write -P 10 0x8000 0x200 |
111 | wait_break A | |
5be5b776 | 112 | break pwritev_rmw_after_head B |
9e1cb96d KW |
113 | aio_write -P 10 0x9e00 0x200 |
114 | wait_break B | |
115 | aio_write -P 11 0x8800 0x1000 | |
116 | resume B | |
117 | sleep 100 | |
118 | resume A | |
119 | aio_flush | |
120 | EOF | |
121 | ||
122 | cat <<EOF | |
5be5b776 | 123 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
124 | aio_write -P 10 0xa000 0x200 |
125 | wait_break A | |
126 | aio_write -P 11 0xa800 0x1000 | |
5be5b776 | 127 | break pwritev_rmw_after_head B |
9e1cb96d KW |
128 | aio_write -P 10 0xbe00 0x200 |
129 | wait_break B | |
130 | resume A | |
131 | sleep 100 | |
132 | resume B | |
133 | aio_flush | |
134 | EOF | |
135 | ||
136 | cat <<EOF | |
5be5b776 | 137 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
138 | aio_write -P 10 0xc000 0x200 |
139 | wait_break A | |
140 | aio_write -P 11 0xc800 0x1000 | |
5be5b776 | 141 | break pwritev_rmw_after_head B |
9e1cb96d KW |
142 | aio_write -P 10 0xde00 0x200 |
143 | wait_break B | |
144 | resume B | |
145 | sleep 100 | |
146 | resume A | |
147 | aio_flush | |
148 | EOF | |
149 | ||
150 | # Only RMW for the tail part | |
151 | cat <<EOF | |
5be5b776 | 152 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
153 | aio_write -P 10 0xe000 0x1800 |
154 | wait_break A | |
155 | aio_write -P 11 0xf000 0xc00 | |
156 | sleep 100 | |
157 | resume A | |
158 | aio_flush | |
159 | EOF | |
160 | ||
161 | cat <<EOF | |
162 | break pwritev A | |
163 | aio_write -P 10 0x10000 0x800 | |
164 | wait_break A | |
5be5b776 | 165 | break pwritev_rmw_after_tail B |
9e1cb96d KW |
166 | aio_write -P 11 0x10000 0x400 |
167 | break pwritev_done C | |
168 | resume A | |
169 | wait_break C | |
170 | resume C | |
171 | sleep 100 | |
172 | wait_break B | |
173 | resume B | |
174 | aio_flush | |
175 | EOF | |
176 | ||
177 | cat <<EOF | |
178 | break pwritev A | |
179 | aio_write -P 10 0x11000 0x800 | |
180 | wait_break A | |
181 | aio_write -P 11 0x11000 0x1000 | |
182 | sleep 100 | |
183 | resume A | |
184 | aio_flush | |
185 | EOF | |
186 | } | |
187 | ||
188 | test_io | $QEMU_IO | _filter_qemu_io | \ | |
189 | sed -e 's,[0-9/]* bytes at offset [0-9]*,XXX/XXX bytes at offset XXX,g' \ | |
190 | -e 's/^[0-9]* \(bytes\|KiB\)/XXX bytes/' \ | |
191 | -e '/Suspended/d' | |
192 | ||
193 | echo | |
194 | echo "== Verify image content ==" | |
195 | ||
196 | function verify_io() | |
197 | { | |
198 | # A simple RMW request | |
199 | echo read -P 0 0 0x200 | |
200 | echo read -P 10 0x200 0x200 | |
201 | echo read -P 0 0x400 0xc00 | |
202 | ||
203 | # Sequential RMW requests on the same physical sector | |
204 | echo read -P 0 0x1000 0x200 | |
205 | echo read -P 10 0x1200 0x200 | |
206 | echo read -P 11 0x1400 0x200 | |
207 | echo read -P 0 0x1600 0xa00 | |
208 | ||
209 | echo read -P 0 0x2000 0x200 | |
210 | echo read -P 10 0x2200 0x200 | |
211 | echo read -P 11 0x2400 0x200 | |
212 | echo read -P 0 0x2600 0xa00 | |
213 | ||
214 | echo read -P 0 0x3000 0x200 | |
215 | echo read -P 10 0x3200 0x200 | |
216 | echo read -P 11 0x3400 0x200 | |
217 | echo read -P 0 0x3600 0xa00 | |
218 | ||
219 | echo read -P 0 0x4000 0x200 | |
220 | echo read -P 10 0x4200 0x200 | |
221 | echo read -P 11 0x4400 0x200 | |
222 | echo read -P 0 0x4600 0xa00 | |
223 | ||
224 | # Chained dependencies | |
225 | echo read -P 10 0x5000 0x200 | |
226 | echo read -P 11 0x5200 0x200 | |
227 | echo read -P 12 0x5400 0x200 | |
228 | echo read -P 13 0x5600 0x200 | |
229 | echo read -P 14 0x5800 0x200 | |
230 | echo read -P 15 0x5a00 0x200 | |
231 | echo read -P 16 0x5c00 0x200 | |
232 | echo read -P 17 0x5e00 0x200 | |
233 | ||
234 | # Overlapping multiple requests | |
235 | echo read -P 10 0x6000 0x200 | |
236 | echo read -P 0 0x6200 0x600 | |
237 | echo read -P 11 0x6800 0x1000 | |
238 | echo read -P 0 0x7800 0x600 | |
239 | echo read -P 10 0x7e00 0x200 | |
240 | ||
241 | echo read -P 10 0x8000 0x200 | |
242 | echo read -P 0 0x8200 0x600 | |
243 | echo read -P 11 0x8800 0x1000 | |
244 | echo read -P 0 0x9800 0x600 | |
245 | echo read -P 10 0x9e00 0x200 | |
246 | ||
247 | echo read -P 10 0xa000 0x200 | |
248 | echo read -P 0 0xa200 0x600 | |
249 | echo read -P 11 0xa800 0x1000 | |
250 | echo read -P 0 0xb800 0x600 | |
251 | echo read -P 10 0xbe00 0x200 | |
252 | ||
253 | echo read -P 10 0xc000 0x200 | |
254 | echo read -P 0 0xc200 0x600 | |
255 | echo read -P 11 0xc800 0x1000 | |
256 | echo read -P 0 0xd800 0x600 | |
257 | echo read -P 10 0xde00 0x200 | |
258 | ||
259 | # Only RMW for the tail part | |
260 | echo read -P 10 0xe000 0x1000 | |
261 | echo read -P 11 0xf800 0x400 | |
262 | echo read -P 0 0xfc00 0x400 | |
263 | ||
264 | echo read -P 11 0x10000 0x400 | |
265 | echo read -P 10 0x10400 0x400 | |
266 | ||
267 | echo read -P 11 0x11800 0x800 | |
268 | } | |
269 | ||
270 | verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io | |
271 | ||
272 | _check_test_img | |
273 | ||
274 | # success, all done | |
275 | echo "*** done" | |
276 | rm -f $seq.full | |
277 | status=0 |