]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
9e1cb96d KW |
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 | owner=kwolf@redhat.com | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
9e1cb96d KW |
27 | status=1 # failure is the default! |
28 | ||
29 | _cleanup() | |
30 | { | |
31 | _cleanup_test_img | |
32 | } | |
33 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
34 | ||
35 | # get standard environment, filters and checks | |
36 | . ./common.rc | |
37 | . ./common.filter | |
38 | ||
f5106206 | 39 | _supported_fmt raw |
9e1cb96d KW |
40 | _supported_proto generic |
41 | _supported_os Linux | |
42 | ||
43 | CLUSTER_SIZE=4k | |
44 | size=128M | |
45 | ||
46 | _make_test_img $size | |
47 | ||
48 | echo | |
49 | echo "== Some concurrent requests involving RMW ==" | |
50 | ||
8cedcffd | 51 | test_io() |
9e1cb96d | 52 | { |
8f9e835f | 53 | echo "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG" |
9e1cb96d KW |
54 | # A simple RMW request |
55 | cat <<EOF | |
56 | aio_write -P 10 0x200 0x200 | |
57 | aio_flush | |
58 | EOF | |
59 | ||
60 | # Sequential RMW requests on the same physical sector | |
61 | off=0x1000 | |
117bc3fa | 62 | for ev in "head" "after_head"; do |
9e1cb96d | 63 | cat <<EOF |
5be5b776 | 64 | break pwritev_rmw_$ev A |
9e1cb96d KW |
65 | aio_write -P 10 $((off + 0x200)) 0x200 |
66 | wait_break A | |
67 | aio_write -P 11 $((off + 0x400)) 0x200 | |
68 | sleep 100 | |
69 | resume A | |
70 | aio_flush | |
71 | EOF | |
72 | off=$((off + 0x1000)) | |
73 | done | |
74 | ||
75 | # Chained dependencies | |
76 | cat <<EOF | |
5be5b776 | 77 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
78 | aio_write -P 10 0x5000 0x200 |
79 | wait_break A | |
80 | aio_write -P 11 0x5200 0x200 | |
81 | aio_write -P 12 0x5400 0x200 | |
82 | aio_write -P 13 0x5600 0x200 | |
83 | aio_write -P 14 0x5800 0x200 | |
84 | aio_write -P 15 0x5a00 0x200 | |
85 | aio_write -P 16 0x5c00 0x200 | |
86 | aio_write -P 17 0x5e00 0x200 | |
87 | sleep 100 | |
88 | resume A | |
89 | aio_flush | |
90 | EOF | |
91 | ||
92 | # Overlapping multiple requests | |
93 | cat <<EOF | |
5be5b776 | 94 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
95 | aio_write -P 10 0x6000 0x200 |
96 | wait_break A | |
5be5b776 | 97 | break pwritev_rmw_after_head B |
9e1cb96d KW |
98 | aio_write -P 10 0x7e00 0x200 |
99 | wait_break B | |
100 | aio_write -P 11 0x6800 0x1000 | |
101 | resume A | |
102 | sleep 100 | |
103 | resume B | |
104 | aio_flush | |
105 | EOF | |
106 | ||
107 | cat <<EOF | |
5be5b776 | 108 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
109 | aio_write -P 10 0x8000 0x200 |
110 | wait_break A | |
5be5b776 | 111 | break pwritev_rmw_after_head B |
9e1cb96d KW |
112 | aio_write -P 10 0x9e00 0x200 |
113 | wait_break B | |
114 | aio_write -P 11 0x8800 0x1000 | |
115 | resume B | |
116 | sleep 100 | |
117 | resume A | |
118 | aio_flush | |
119 | EOF | |
120 | ||
121 | cat <<EOF | |
5be5b776 | 122 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
123 | aio_write -P 10 0xa000 0x200 |
124 | wait_break A | |
125 | aio_write -P 11 0xa800 0x1000 | |
5be5b776 | 126 | break pwritev_rmw_after_head B |
9e1cb96d KW |
127 | aio_write -P 10 0xbe00 0x200 |
128 | wait_break B | |
129 | resume A | |
130 | sleep 100 | |
131 | resume B | |
132 | aio_flush | |
133 | EOF | |
134 | ||
135 | cat <<EOF | |
5be5b776 | 136 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
137 | aio_write -P 10 0xc000 0x200 |
138 | wait_break A | |
139 | aio_write -P 11 0xc800 0x1000 | |
5be5b776 | 140 | break pwritev_rmw_after_head B |
9e1cb96d KW |
141 | aio_write -P 10 0xde00 0x200 |
142 | wait_break B | |
143 | resume B | |
144 | sleep 100 | |
145 | resume A | |
146 | aio_flush | |
147 | EOF | |
148 | ||
149 | # Only RMW for the tail part | |
150 | cat <<EOF | |
5be5b776 | 151 | break pwritev_rmw_after_tail A |
9e1cb96d KW |
152 | aio_write -P 10 0xe000 0x1800 |
153 | wait_break A | |
154 | aio_write -P 11 0xf000 0xc00 | |
155 | sleep 100 | |
156 | resume A | |
157 | aio_flush | |
158 | EOF | |
159 | ||
160 | cat <<EOF | |
161 | break pwritev A | |
162 | aio_write -P 10 0x10000 0x800 | |
163 | wait_break A | |
5be5b776 | 164 | break pwritev_rmw_after_tail B |
9e1cb96d KW |
165 | aio_write -P 11 0x10000 0x400 |
166 | break pwritev_done C | |
167 | resume A | |
168 | wait_break C | |
169 | resume C | |
170 | sleep 100 | |
171 | wait_break B | |
172 | resume B | |
173 | aio_flush | |
174 | EOF | |
175 | ||
176 | cat <<EOF | |
177 | break pwritev A | |
178 | aio_write -P 10 0x11000 0x800 | |
179 | wait_break A | |
180 | aio_write -P 11 0x11000 0x1000 | |
181 | sleep 100 | |
182 | resume A | |
183 | aio_flush | |
184 | EOF | |
185 | } | |
186 | ||
187 | test_io | $QEMU_IO | _filter_qemu_io | \ | |
188 | sed -e 's,[0-9/]* bytes at offset [0-9]*,XXX/XXX bytes at offset XXX,g' \ | |
189 | -e 's/^[0-9]* \(bytes\|KiB\)/XXX bytes/' \ | |
d04c1555 FZ |
190 | -e '/Suspended/d' \ |
191 | -e '/blkdebug: Resuming request/d' | |
9e1cb96d KW |
192 | |
193 | echo | |
194 | echo "== Verify image content ==" | |
195 | ||
8cedcffd | 196 | verify_io() |
9e1cb96d KW |
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 | ||
9e1cb96d KW |
214 | # Chained dependencies |
215 | echo read -P 10 0x5000 0x200 | |
216 | echo read -P 11 0x5200 0x200 | |
217 | echo read -P 12 0x5400 0x200 | |
218 | echo read -P 13 0x5600 0x200 | |
219 | echo read -P 14 0x5800 0x200 | |
220 | echo read -P 15 0x5a00 0x200 | |
221 | echo read -P 16 0x5c00 0x200 | |
222 | echo read -P 17 0x5e00 0x200 | |
223 | ||
224 | # Overlapping multiple requests | |
225 | echo read -P 10 0x6000 0x200 | |
226 | echo read -P 0 0x6200 0x600 | |
227 | echo read -P 11 0x6800 0x1000 | |
228 | echo read -P 0 0x7800 0x600 | |
229 | echo read -P 10 0x7e00 0x200 | |
230 | ||
231 | echo read -P 10 0x8000 0x200 | |
232 | echo read -P 0 0x8200 0x600 | |
233 | echo read -P 11 0x8800 0x1000 | |
234 | echo read -P 0 0x9800 0x600 | |
235 | echo read -P 10 0x9e00 0x200 | |
236 | ||
237 | echo read -P 10 0xa000 0x200 | |
238 | echo read -P 0 0xa200 0x600 | |
239 | echo read -P 11 0xa800 0x1000 | |
240 | echo read -P 0 0xb800 0x600 | |
241 | echo read -P 10 0xbe00 0x200 | |
242 | ||
243 | echo read -P 10 0xc000 0x200 | |
244 | echo read -P 0 0xc200 0x600 | |
245 | echo read -P 11 0xc800 0x1000 | |
246 | echo read -P 0 0xd800 0x600 | |
247 | echo read -P 10 0xde00 0x200 | |
248 | ||
249 | # Only RMW for the tail part | |
250 | echo read -P 10 0xe000 0x1000 | |
251 | echo read -P 11 0xf800 0x400 | |
252 | echo read -P 0 0xfc00 0x400 | |
253 | ||
254 | echo read -P 11 0x10000 0x400 | |
255 | echo read -P 10 0x10400 0x400 | |
256 | ||
257 | echo read -P 11 0x11800 0x800 | |
258 | } | |
259 | ||
260 | verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io | |
261 | ||
262 | _check_test_img | |
263 | ||
264 | # success, all done | |
265 | echo "*** done" | |
266 | rm -f $seq.full | |
267 | status=0 |