qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/2] iotests/108: Test new refcount rebuild algorithm


From: Hanna Reitz
Subject: Re: [PATCH v2 2/2] iotests/108: Test new refcount rebuild algorithm
Date: Fri, 1 Apr 2022 15:55:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 30.03.22 17:07, Eric Blake wrote:
On Tue, Mar 29, 2022 at 11:19:17AM +0200, Hanna Reitz wrote:
One clear problem with how qcow2's refcount structure rebuild algorithm
used to be before "qcow2: Improve refcount structure rebuilding" was
that it is prone to failure for qcow2 images on block devices: There is
generally unused space after the actual image, and if that exceeds what
one refblock covers, the old algorithm would invariably write the
reftable past the block device's end, which cannot work.  The new
algorithm does not have this problem.

Test it with three tests:
(1) Create an image with more empty space at the end than what one
     refblock covers, see whether rebuilding the refcount structures
     results in a change in the image file length.  (It should not.)

(2) Leave precisely enough space somewhere at the beginning of the image
     for the new reftable (and the refblock for that place), see whether
     the new algorithm puts the reftable there.  (It should.)

(3) Test the original problem: Create (something like) a block device
     with a fixed size, then create a qcow2 image in there, write some
     data, and then have qemu-img check rebuild the refcount structures.
     Before HEAD^, the reftable would have been written past the image
     file end, i.e. outside of what the block device provides, which
     cannot work.  HEAD^ should have fixed that.
     ("Something like a block device" means a loop device if we can use
     one ("sudo -n losetup" works), or a FUSE block export with
     growable=false otherwise.)
NBD might work for that purpose as well.  But no need to rewrite your
test for yet another block-alike behavior ;)

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
  tests/qemu-iotests/108     | 259 ++++++++++++++++++++++++++++++++++++-
  tests/qemu-iotests/108.out |  81 ++++++++++++
  2 files changed, 339 insertions(+), 1 deletion(-)

[...]

+if $loopdev; then
+    export_mp=$(sudo -n losetup --show -f "$TEST_IMG")
+    export_mp_driver=host_device
+    sudo -n chmod go+rw "$export_mp"
+else
+    # Create non-growable FUSE export that is a bit like an empty
+    # block device
+    export_mp="$TEST_DIR/fuse-export"
+    export_mp_driver=file
+    touch "$export_mp"
+
+    $QSD \
+        --blockdev file,node-name=export-node,filename="$TEST_IMG" \
+        --export 
fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off
 \
+        --pidfile "$TEST_DIR/qsd.pid" \
+        --daemonize
+fi
+
+# Now create a qcow2 image on the device -- unfortunately, qemu-img
+# create force-creates the file, so we have to resort to the
+# blockdev-create job.
Huh. Why do we have 'qemu-img convert -n' but not 'qemu-img create -n'
for writing a particular destination format into an already existing
storage space?

`qemu-img convert -n` is actually different than what `qemu-img create -n` would be.  The former will not create the image format either, and so you can’t emulate the latter’s behavior with something like `qemu-img convert -n null-co:// target.qcow2`.

I think at some point I dabbled with a `qemu-img create -n`, but didn’t really get anywhere.  I don’t remember why, I think it had something to do with that if you don’t want to create the protocol layer, you will have to use the blockdev-create infrastructure, and can’t use bdrv_img_create().  So it all became a bit more complicated than I’d hoped for.

Maybe a `run-job` subcommand for qemu-img might be a reasonable stop-gap.

(Again, thanks for the review!)

Hanna




reply via email to

[Prev in Thread] Current Thread [Next in Thread]