[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Reset free_cluster_index when allocating
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Reset free_cluster_index when allocating a new refcount block |
Date: |
Wed, 21 Mar 2018 08:30:11 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 03/20/2018 08:55 AM, Alberto Garcia wrote:
When we try to allocate new clusters we first look for available ones
starting from s->free_cluster_index and once we find them we increase
their reference counts. Before we get to call update_refcount() to do
this last step s->free_cluster_index is already pointing to the next
cluster after the ones we are trying to allocate.
This can be reproduced easily:
qemu-img create -f qcow2 -o cluster_size=512 hd.qcow2 1M
qemu-io -c 'write 0 124k' hd.qcow2
This reproduction fails if you use non-default refcount_order...
+++ b/tests/qemu-iotests/121
@@ -93,6 +93,26 @@ $QEMU_IO -c 'write 63M 130K' "$TEST_IMG" | _filter_qemu_io
_check_test_img
+echo
+echo '=== Allocating a new refcount block must not leave holes in the image
==='
+echo
+
+IMGOPTS='cluster_size=512' _make_test_img 1M
...so here, I think IMGOPTS also has to include refcount_bits=4, so that
calling iotests './check -o refcount_bits=3' or similar doesn't fail the
test.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org