From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Lieven <pl@kamp.de>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 21/21] iotests: Add test for different refcount widths
Date: Mon, 17 Nov 2014 12:02:18 +0100 [thread overview]
Message-ID: <5469D5BA.3080800@redhat.com> (raw)
In-Reply-To: <5469D012.4030404@redhat.com>
On 2014-11-17 at 11:38, Max Reitz wrote:
> On 2014-11-17 at 09:34, Max Reitz wrote:
>> On 2014-11-15 at 15:50, Eric Blake wrote:
>>> On 11/14/2014 06:06 AM, Max Reitz wrote:
>>>> Add a test for conversion between different refcount widths and errors
>>>> specific to certain widths (i.e. snapshots with refcount_width=1).
>>>>
>>>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>>>> ---
>>>> tests/qemu-iotests/112 | 252
>>>> +++++++++++++++++++++++++++++++++++++++++++++
>>>> tests/qemu-iotests/112.out | 131 +++++++++++++++++++++++
>>>> tests/qemu-iotests/group | 1 +
>>>> 3 files changed, 384 insertions(+)
>>>> create mode 100755 tests/qemu-iotests/112
>>>> create mode 100644 tests/qemu-iotests/112.out
>>>>
>>>> +echo
>>>> +echo '=== Testing too many references for check ==='
>>>> +echo
>>>> +
>>>> +IMGOPTS="$IMGOPTS,refcount_width=1" _make_test_img 64M
>>>> +print_refcount_width
>>>> +
>>>> +# This cluster should be created at 0x50000
>>>> +$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
>>>> +# Now make the second L2 entry (the L2 table should be at 0x40000)
>>>> point to that
>>>> +# cluster, so we have two references
>>>> +poke_file "$TEST_IMG" $((0x40008)) "\x80\x00\x00\x00\x00\x05\x00\x00"
>>>> +
>>>> +# This should say "please use amend"
>>>> +_check_test_img -r all
>>>> +
>>>> +# So we do that
>>>> +$QEMU_IMG amend -o refcount_width=2 "$TEST_IMG"
>>>> +print_refcount_width
>>>> +
>>>> +# And try again
>>>> +_check_test_img -r all
>>> I think this section also deserves a test that fuzzes an image with
>>> width=64 to intentionally set the most significant bit of one of the
>>> refcounts, and make sure that we gracefully diagnose it as invalid.
>>>
>>>> +
>>>> +echo
>>>> +echo '=== Multiple walks necessary during amend ==='
>>>> +echo
>>>> +
>>>> +IMGOPTS="$IMGOPTS,refcount_width=1,cluster_size=512"
>>>> _make_test_img 64k
>>>> +
>>>> +# Cluster 0 is the image header, clusters 1 to 4 are used by the
>>>> L1 table, a
>>>> +# single L2 table, the reftable and a single refblock. This
>>>> creates 58 data
>>>> +# clusters (actually, the L2 table is created here, too), so in
>>>> total there are
>>>> +# then 63 used clusters in the image. With a refcount width of 64,
>>>> one refblock
>>>> +# describes 64 clusters (512 bytes / 64 bits/entry = 64 entries),
>>>> so this will
>>>> +# make the first target refblock have exactly one free entry.
>>>> +$QEMU_IO -c "write 0 $((58 * 512))" "$TEST_IMG" | _filter_qemu_io
>>>> +
>>>> +# Now change the refcount width; since the first target refblock
>>>> has exactly one
>>>> +# free entry, that entry will be used to store its own reference.
>>>> No other
>>>> +# refblocks are needed, so then the new reftable will be
>>>> allocated; since the
>>>> +# first target refblock is completely filled up, this will require
>>>> a new
>>>> +# refblock which is why the refcount width changing function will
>>>> need to run
>>>> +# through everything one more time until the allocations are stable.
>>>> +$QEMU_IMG amend -o refcount_width=64 "$TEST_IMG"
>>>> +print_refcount_width
>>> Umm, that sounds backwards from what you document. It's a good test of
>>> the _new_ reftable needing a second round of allocations. So keep it
>>> with corrected comments. But I think you _intended_ to write a test
>>> that starts with a refcount_width=64 image and resize to a
>>> refcount_width=1, where the _old_ reftable then suffers a reallocation
>>> as part of allocating refblocks for the new table.
>>
>> That's what you intended, but that's harder to test, so I settled for
>> this (and the comments are appropriate (note that "target refblock"
>> refers to the refblocks after amendment); note that this does indeed
>> fail with v1 of this series.
>>
>>> It may even help if
>>> you add a tracepoint for every iteration through the walk function
>>> callback, to prove we are indeed executing it 3 times instead of the
>>> usual 2, for these test cases.
>>
>> That's a good idea! I thought about adding some info, but totally
>> forgot about trace points.
>
> ...On second thought, trace doesn't work so well with qemu-img. My
> best bet would be blkdebug, but that seems kind of ugly to me...
Problem "solved": If there will be more walks than originally thought
(3+1 instead of 2+1), progress will regress at one point. I'll just grep
for that point and that should be enough (progress jumping from 66.67 %
to 50.00 %).
Max
next prev parent reply other threads:[~2014-11-17 11:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 13:05 [Qemu-devel] [PATCH v2 00/21] qcow2: Support refcount orders != 4 Max Reitz
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 01/21] qcow2: Add two new fields to BDRVQcowState Max Reitz
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 02/21] qcow2: Add refcount_width to format-specific info Max Reitz
2014-11-15 16:00 ` Eric Blake
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 03/21] qcow2: Use 64 bits for refcount values Max Reitz
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 04/21] qcow2: Respect error in qcow2_alloc_bytes() Max Reitz
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 05/21] qcow2: Refcount overflow and qcow2_alloc_bytes() Max Reitz
2014-11-14 13:05 ` [Qemu-devel] [PATCH v2 06/21] qcow2: Helper for refcount array reallocation Max Reitz
2014-11-15 16:50 ` Eric Blake
2014-11-17 8:37 ` Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 07/21] qcow2: Helper function for refcount modification Max Reitz
2014-11-15 17:02 ` Eric Blake
2014-11-17 8:42 ` Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 08/21] qcow2: More helpers " Max Reitz
2014-11-15 17:08 ` Eric Blake
2014-11-17 8:44 ` Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 09/21] qcow2: Open images with refcount order != 4 Max Reitz
2014-11-15 17:09 ` Eric Blake
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 10/21] qcow2: refcount_order parameter for qcow2_create2 Max Reitz
2014-11-15 17:13 ` Eric Blake
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 11/21] iotests: Prepare for refcount_width option Max Reitz
2014-11-15 17:17 ` Eric Blake
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 12/21] qcow2: Allow creation with refcount order != 4 Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 13/21] block: Add opaque value to the amend CB Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 14/21] qcow2: Use error_report() in qcow2_amend_options() Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 15/21] qcow2: Use abort() instead of assert(false) Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 16/21] qcow2: Split upgrade/downgrade paths for amend Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 17/21] qcow2: Use intermediate helper CB " Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 18/21] qcow2: Add function for refcount order amendment Max Reitz
2014-11-18 17:55 ` Eric Blake
2014-11-18 18:58 ` Max Reitz
2014-11-18 19:56 ` Eric Blake
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 19/21] qcow2: Invoke refcount order amendment function Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 20/21] qcow2: Point to amend function in check Max Reitz
2014-11-14 13:06 ` [Qemu-devel] [PATCH v2 21/21] iotests: Add test for different refcount widths Max Reitz
2014-11-15 14:50 ` Eric Blake
2014-11-17 8:34 ` Max Reitz
2014-11-17 10:38 ` Max Reitz
2014-11-17 11:02 ` Max Reitz [this message]
2014-11-17 12:06 ` Max Reitz
2014-11-18 20:26 ` Eric Blake
2014-11-19 5:52 ` Eric Blake
2014-11-20 14:03 ` Max Reitz
2014-11-20 21:21 ` Eric Blake
2014-11-20 13:48 ` Max Reitz
2014-11-20 21:27 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5469D5BA.3080800@redhat.com \
--to=mreitz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).