3 # Test concurrent cluster allocations
5 # Copyright (C) 2012 Red Hat, Inc.
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.
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.
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/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
29 status
=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 _supported_proto generic
49 echo "== creating backing file for COW tests =="
61 for i
in $
(seq 0 $
((sectors
- 1))); do
62 cur_sec
=$
((offset
/ 65536 + i
))
63 pattern
=$
(( ( (cur_sec
% 128) + (cur_sec
/ 128)) % 128 ))
65 echo "$op -P $pattern $((cur_sec * 64))k 64k"
69 backing_io
0 16 write |
$QEMU_IO $TEST_IMG | _filter_qemu_io
71 mv $TEST_IMG $TEST_IMG.base
73 _make_test_img
-b $TEST_IMG.base
6G
76 echo "== Some concurrent requests touching the same cluster =="
80 # Allocate middle of cluster 1, then write to somewhere before and after it
83 aio_write -P 10 0x18000 0x2000
86 aio_write -P 11 0x12000 0x2000
87 aio_write -P 12 0x1c000 0x2000
93 # Sequential write case: Alloc middle of cluster 2, then write overlapping
97 aio_write -P 20 0x28000 0x2000
99 aio_write -P 21 0x2a000 0x10000
104 # The same with a gap between both requests
107 aio_write -P 40 0x48000 0x2000
109 aio_write -P 41 0x4c000 0x10000
114 # Sequential write, but the next cluster is already allocated
116 write -P 70 0x76000 0x8000
119 aio_write -P 60 0x66000 0x2000
121 aio_write -P 61 0x6a000 0xe000
126 # Sequential write, but the next cluster is already allocated
127 # and phyiscally in the right position
129 write -P 89 0x80000 0x1000
130 write -P 90 0x96000 0x8000
132 discard 0x80000 0x10000
135 aio_write -P 80 0x86000 0x2000
137 aio_write -P 81 0x8a000 0xe000
142 # Sequential write, and the next cluster is compressed
144 write -P 109 0xa0000 0x1000
145 write -c -P 110 0xb0000 0x10000
147 discard 0xa0000 0x10000
150 aio_write -P 100 0xa6000 0x2000
152 aio_write -P 101 0xaa000 0xe000
158 overlay_io |
$QEMU_IO blkdebug
::$TEST_IMG | _filter_qemu_io |\
159 sed -e 's/bytes at offset [0-9]*/bytes at offset XXX/g'
162 echo "== Verify image content =="
166 echo read -P 0 0 0x10000
168 echo read -P 1 0x10000 0x2000
169 echo read -P 11 0x12000 0x2000
170 echo read -P 1 0x14000 0x4000
171 echo read -P 10 0x18000 0x2000
172 echo read -P 1 0x1a000 0x2000
173 echo read -P 12 0x1c000 0x2000
174 echo read -P 1 0x1e000 0x2000
176 echo read -P 2 0x20000 0x8000
177 echo read -P 20 0x28000 0x2000
178 echo read -P 21 0x2a000 0x10000
179 echo read -P 3 0x3a000 0x6000
181 echo read -P 4 0x40000 0x8000
182 echo read -P 40 0x48000 0x2000
183 echo read -P 4 0x4a000 0x2000
184 echo read -P 41 0x4c000 0x10000
185 echo read -P 5 0x5c000 0x4000
187 echo read -P 6 0x60000 0x6000
188 echo read -P 60 0x66000 0x2000
189 echo read -P 6 0x68000 0x2000
190 echo read -P 61 0x6a000 0xe000
191 echo read -P 70 0x78000 0x6000
192 echo read -P 7 0x7e000 0x2000
194 echo read -P 8 0x80000 0x6000
195 echo read -P 80 0x86000 0x2000
196 echo read -P 8 0x88000 0x2000
197 echo read -P 81 0x8a000 0xe000
198 echo read -P 90 0x98000 0x6000
199 echo read -P 9 0x9e000 0x2000
201 echo read -P 10 0xa0000 0x6000
202 echo read -P 100 0xa6000 0x2000
203 echo read -P 10 0xa8000 0x2000
204 echo read -P 101 0xaa000 0xe000
205 echo read -P 110 0xb8000 0x8000
208 verify_io |
$QEMU_IO $TEST_IMG | _filter_qemu_io