rcu: optimize rcu_read_lock
[qemu/ar7.git] / tests / qemu-iotests / 115
bloba6be1876aa1618c82efefea26a4bfda062b9cc66
1 #!/bin/bash
3 # Test case for non-self-referential qcow2 refcount blocks
5 # Copyright (C) 2014 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/>.
21 # creator
22 owner=mreitz@redhat.com
24 seq="$(basename $0)"
25 echo "QA output created by $seq"
27 here="$PWD"
28 tmp=/tmp/$$
29 status=1 # failure is the default!
31 _cleanup()
33 _cleanup_test_img
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
41 _supported_fmt qcow2
42 _supported_proto file
43 _supported_os Linux
44 # This test relies on refcounts being 64 bits wide (which does not work with
45 # compat=0.10)
46 _unsupported_imgopts 'refcount_bits=\([^6]\|.\([^4]\|$\)\)' 'compat=0.10'
48 echo
49 echo '=== Testing large refcount and L1 table ==='
50 echo
52 # Create an image with an L1 table and a refcount table that each span twice the
53 # number of clusters which can be described by a single refblock; therefore, at
54 # least two refblocks cannot count their own refcounts because all the clusters
55 # they describe are part of the L1 table or refcount table.
57 # One refblock can describe (with cluster_size=512 and refcount_bits=64)
58 # 512/8 = 64 clusters, therefore the L1 table should cover 128 clusters, which
59 # equals 128 * (512/8) = 8192 entries (actually, 8192 - 512/8 = 8129 would
60 # suffice, but it does not really matter). 8192 L2 tables can in turn describe
61 # 8192 * 512/8 = 524,288 clusters which cover a space of 256 MB.
63 # Since with refcount_bits=64 every refcount block entry is 64 bits wide (just
64 # like the L2 table entries), the same calculation applies to the refcount table
65 # as well; the difference is that while for the L1 table the guest disk size is
66 # concerned, for the refcount table it is the image length that has to be at
67 # least 256 MB. We can achieve that by using preallocation=metadata for an image
68 # which has a guest disk size of 256 MB.
70 IMGOPTS="$IMGOPTS,refcount_bits=64,cluster_size=512,preallocation=metadata" \
71 _make_test_img 256M
73 # We know for sure that the L1 and refcount tables do not overlap with any other
74 # structure because the metadata overlap checks would have caught that case.
76 # Because qemu refuses to open qcow2 files whose L1 table does not cover the
77 # whole guest disk size, it is definitely large enough. On the other hand, to
78 # test whether the refcount table is large enough, we simply have to verify that
79 # indeed all the clusters are allocated, which is done by qemu-img check.
81 # The final thing we need to test is whether the tables are actually covered by
82 # refcount blocks; since all clusters of the tables are referenced, we can use
83 # qemu-img check for that purpose, too.
85 $QEMU_IMG check "$TEST_IMG" | \
86 sed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
87 -e '/^Image end offset/d'
89 # (Note that we cannot use _check_test_img because that function filters out the
90 # allocation status)
92 # success, all done
93 echo '*** done'
94 rm -f $seq.full
95 status=0