Skip to content

qcow2: Improve refcount structure rebuilding

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2072379
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45636266
Upstream status: merged

When the qcow2 refcount structure is broken to a point where we cannot rely on any information from it (because it shows clusters as free that are in use), “qemu-img check -r all” completely rewrites it.

The new reftable is preferably written into the area covered by the last refblock for the image, but if that refblock is empty (e.g. because the image is on a block device and there is just nothing near the end of the block device), then the reftable will be put after the image’s end. Which is a problem on block devices, because they can’t easily be resized (also, resizing wouldn’t really help in this case, because the reftable would still be written past the new end).

Effectively, this means you can’t run qemu-img check -r all on qcow2 images that are on block devices when there are clusters that are in use, but not marked as allocated. Patch 1 modifies the algorithm to put the reftable into the first free space in the image instead, patch 2 adds a test, and patch 3 adds Error ** parameters throughout these refcount rebuilding functions.

git backport-diff against upstream:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/4:[----] [--] 'qcow2: Improve refcount structure rebuilding'
002/4:[0006] [FC] 'iotests/108: Test new refcount rebuild algorithm'
003/4:[----] [--] 'qcow2: Add errp to rebuild_refcount_structure()'
004/4:[----] [-C] 'iotests/108: Fix when missing user_allow_other'

(Same as for RHEL 8.)

Signed-off-by: Hanna Reitz hreitz@redhat.com

Merge request reports

Loading