blob: d2d2a2d6876a769617ee9ededd6e3aec3caeb0ed [file] [log] [blame]
Kevin Wolf9e1cb962014-01-14 15:37:03 +01001#!/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
22owner=kwolf@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
Kevin Wolf9e1cb962014-01-14 15:37:03 +010028status=1 # failure is the default!
29
30_cleanup()
31{
32 _cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39
Kevin Wolff5106202014-01-30 12:52:47 +010040_supported_fmt raw
Kevin Wolf9e1cb962014-01-14 15:37:03 +010041_supported_proto generic
42_supported_os Linux
43
44CLUSTER_SIZE=4k
45size=128M
46
47_make_test_img $size
48
49echo
50echo "== Some concurrent requests involving RMW =="
51
52function test_io()
53{
Kevin Wolf8f9e8352014-11-20 16:27:07 +010054echo "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG"
Kevin Wolf9e1cb962014-01-14 15:37:03 +010055# A simple RMW request
56cat <<EOF
57aio_write -P 10 0x200 0x200
58aio_flush
59EOF
60
61# Sequential RMW requests on the same physical sector
62off=0x1000
Peter Lieven117bc3f2016-05-30 13:31:13 +020063for ev in "head" "after_head"; do
Kevin Wolf9e1cb962014-01-14 15:37:03 +010064cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -070065break pwritev_rmw_$ev A
Kevin Wolf9e1cb962014-01-14 15:37:03 +010066aio_write -P 10 $((off + 0x200)) 0x200
67wait_break A
68aio_write -P 11 $((off + 0x400)) 0x200
69sleep 100
70resume A
71aio_flush
72EOF
73off=$((off + 0x1000))
74done
75
76# Chained dependencies
77cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -070078break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +010079aio_write -P 10 0x5000 0x200
80wait_break A
81aio_write -P 11 0x5200 0x200
82aio_write -P 12 0x5400 0x200
83aio_write -P 13 0x5600 0x200
84aio_write -P 14 0x5800 0x200
85aio_write -P 15 0x5a00 0x200
86aio_write -P 16 0x5c00 0x200
87aio_write -P 17 0x5e00 0x200
88sleep 100
89resume A
90aio_flush
91EOF
92
93# Overlapping multiple requests
94cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -070095break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +010096aio_write -P 10 0x6000 0x200
97wait_break A
Eric Blake5be5b772015-11-18 01:52:55 -070098break pwritev_rmw_after_head B
Kevin Wolf9e1cb962014-01-14 15:37:03 +010099aio_write -P 10 0x7e00 0x200
100wait_break B
101aio_write -P 11 0x6800 0x1000
102resume A
103sleep 100
104resume B
105aio_flush
106EOF
107
108cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -0700109break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100110aio_write -P 10 0x8000 0x200
111wait_break A
Eric Blake5be5b772015-11-18 01:52:55 -0700112break pwritev_rmw_after_head B
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100113aio_write -P 10 0x9e00 0x200
114wait_break B
115aio_write -P 11 0x8800 0x1000
116resume B
117sleep 100
118resume A
119aio_flush
120EOF
121
122cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -0700123break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100124aio_write -P 10 0xa000 0x200
125wait_break A
126aio_write -P 11 0xa800 0x1000
Eric Blake5be5b772015-11-18 01:52:55 -0700127break pwritev_rmw_after_head B
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100128aio_write -P 10 0xbe00 0x200
129wait_break B
130resume A
131sleep 100
132resume B
133aio_flush
134EOF
135
136cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -0700137break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100138aio_write -P 10 0xc000 0x200
139wait_break A
140aio_write -P 11 0xc800 0x1000
Eric Blake5be5b772015-11-18 01:52:55 -0700141break pwritev_rmw_after_head B
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100142aio_write -P 10 0xde00 0x200
143wait_break B
144resume B
145sleep 100
146resume A
147aio_flush
148EOF
149
150# Only RMW for the tail part
151cat <<EOF
Eric Blake5be5b772015-11-18 01:52:55 -0700152break pwritev_rmw_after_tail A
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100153aio_write -P 10 0xe000 0x1800
154wait_break A
155aio_write -P 11 0xf000 0xc00
156sleep 100
157resume A
158aio_flush
159EOF
160
161cat <<EOF
162break pwritev A
163aio_write -P 10 0x10000 0x800
164wait_break A
Eric Blake5be5b772015-11-18 01:52:55 -0700165break pwritev_rmw_after_tail B
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100166aio_write -P 11 0x10000 0x400
167break pwritev_done C
168resume A
169wait_break C
170resume C
171sleep 100
172wait_break B
173resume B
174aio_flush
175EOF
176
177cat <<EOF
178break pwritev A
179aio_write -P 10 0x11000 0x800
180wait_break A
181aio_write -P 11 0x11000 0x1000
182sleep 100
183resume A
184aio_flush
185EOF
186}
187
188test_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
193echo
194echo "== Verify image content =="
195
196function 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
Kevin Wolf9e1cb962014-01-14 15:37:03 +0100214 # 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
260verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
261
262_check_test_img
263
264# success, all done
265echo "*** done"
266rm -f $seq.full
267status=0