root / tests / qemu-iotests / 038 @ 9a05feab
History | View | Annotate | Download (3.1 kB)
1 |
#!/bin/bash |
---|---|
2 |
# |
3 |
# Test COW from backing files with AIO |
4 |
# |
5 |
# Copyright (C) 2012 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 |
|
27 |
here=`pwd` |
28 |
tmp=/tmp/$$ |
29 |
status=1 # failure is the default! |
30 |
|
31 |
_cleanup() |
32 |
{ |
33 |
_cleanup_test_img |
34 |
} |
35 |
trap "_cleanup; exit \$status" 0 1 2 3 15 |
36 |
|
37 |
# get standard environment, filters and checks |
38 |
. ./common.rc |
39 |
. ./common.filter |
40 |
|
41 |
_supported_fmt qcow2 qed |
42 |
_supported_proto file |
43 |
_supported_os Linux |
44 |
|
45 |
CLUSTER_SIZE=2M |
46 |
size=128M |
47 |
|
48 |
echo |
49 |
echo "== creating backing file for COW tests ==" |
50 |
|
51 |
_make_test_img $size |
52 |
|
53 |
function backing_io() |
54 |
{ |
55 |
local offset=$1 |
56 |
local sectors=$2 |
57 |
local op=$3 |
58 |
local pattern=0 |
59 |
local cur_sec=0 |
60 |
|
61 |
for i in $(seq 0 $((sectors - 1))); do |
62 |
cur_sec=$((offset / 65536 + i)) |
63 |
pattern=$(( ( (cur_sec % 128) + (cur_sec / 128)) % 128 )) |
64 |
|
65 |
echo "$op -P $pattern $((cur_sec * 64))k 64k" |
66 |
done |
67 |
} |
68 |
|
69 |
backing_io 0 256 write | $QEMU_IO "$TEST_IMG" | _filter_qemu_io |
70 |
|
71 |
mv "$TEST_IMG" "$TEST_IMG.base" |
72 |
|
73 |
_make_test_img -b "$TEST_IMG.base" 6G |
74 |
|
75 |
echo |
76 |
echo "== Some concurrent requests touching the same cluster ==" |
77 |
|
78 |
function overlay_io() |
79 |
{ |
80 |
# Start with a request touching two clusters |
81 |
echo aio_write -P 0x80 2020k 80k |
82 |
|
83 |
# Then add some requests all over the place |
84 |
for i in $(seq 0 15; seq 17 31; seq 33 47); do |
85 |
echo aio_write -P $((0x81 + i)) $((i * 128))k 64k |
86 |
done |
87 |
|
88 |
# Then backwards overwriting part of them |
89 |
for i in $( (seq 0 15; seq 17 31; seq 33 47) | tac); do |
90 |
echo aio_write -P $((0x81 + i)) $((i * 128 + 32))k 64k |
91 |
done |
92 |
|
93 |
# And finally crossing the next cluster boundary |
94 |
echo aio_write -P 0x90 4080k 80k |
95 |
} |
96 |
|
97 |
overlay_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io |\ |
98 |
sed -e 's/bytes at offset [0-9]*/bytes at offset XXX/g' \ |
99 |
-e 's/qemu-io> //g' | paste - - | sort | tr '\t' '\n' |
100 |
|
101 |
echo |
102 |
echo "== Verify image content ==" |
103 |
|
104 |
function verify_io() |
105 |
{ |
106 |
echo read -P 31 2016k 4k |
107 |
echo read -P 0x80 2020k 80k |
108 |
echo read -P 32 2100k 12k |
109 |
echo read -P 33 2112k 64k |
110 |
|
111 |
echo read -P 63 4064k 16k |
112 |
echo read -P 0x90 4080k 80k |
113 |
echo read -P 65 4160k 64k |
114 |
|
115 |
for i in $(seq 0 15; seq 17 31; seq 33 47); do |
116 |
echo read -P $((0x81 + i)) $((i * 128))k 96k |
117 |
done |
118 |
|
119 |
for i in $(seq 0 14; seq 16 30; seq 32 47); do |
120 |
local cur_sec=$(( i * 2 + 1 )) |
121 |
local pattern=$(( ( (cur_sec % 128) + (cur_sec / 128)) % 128 )) |
122 |
|
123 |
echo read -P $pattern $((i * 128 + 96))k 32k |
124 |
done |
125 |
} |
126 |
|
127 |
verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io |
128 |
|
129 |
_check_test_img |
130 |
|
131 |
# success, all done |
132 |
echo "*** done" |
133 |
rm -f $seq.full |
134 |
status=0 |