]> Git Repo - qemu.git/commit
qcow2: Fix preallocation on images with unaligned sizes
authorAlberto Garcia <[email protected]>
Wed, 17 Jun 2020 14:00:36 +0000 (16:00 +0200)
committerMax Reitz <[email protected]>
Mon, 6 Jul 2020 06:33:06 +0000 (08:33 +0200)
commita5675f390116a927e320984f02f473a6affc9fcd
tree33283366384bc7c3703cf36c497761c4afd7c018
parente8de7ba9ea086c427cd36a10bc3506ac20aa4895
qcow2: Fix preallocation on images with unaligned sizes

When resizing an image with qcow2_co_truncate() using the falloc or
full preallocation modes the code assumes that both the old and new
sizes are cluster-aligned.

There are two problems with this:

  1) The calculation of how many clusters are involved does not always
     get the right result.

     Example: creating a 60KB image and resizing it (with
     preallocation=full) to 80KB won't allocate the second cluster.

  2) No copy-on-write is performed, so in the previous example if
     there is a backing file then the first 60KB of the first cluster
     won't be filled with data from the backing file.

This patch fixes both issues.

Signed-off-by: Alberto Garcia <[email protected]>
Message-Id: <20200617140036[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
block/qcow2.c
tests/qemu-iotests/125
tests/qemu-iotests/125.out
This page took 0.027709 seconds and 4 git commands to generate.