qcow2: Don't strand clusters near 2G intervals during commit
authorEric Blake <eblake@redhat.com>
Mon, 5 Dec 2016 15:49:34 +0000 (09:49 -0600)
committerKevin Wolf <kwolf@redhat.com>
Tue, 6 Dec 2016 14:37:02 +0000 (15:37 +0100)
commita3e1505daec31ef56f0489f8c8fff1b8e4ca92bd
tree2614453febab9387fbaae68a83cf8b27f76a5109
parentbc66cedb4141fb7588f2462c74310d8fb5dd4cf1
qcow2: Don't strand clusters near 2G intervals during commit

The qcow2_make_empty() function is reached during 'qemu-img commit',
in order to clear out ALL clusters of an image.  However, if the
image cannot use the fast code path (true if the image is format
0.10, or if the image contains a snapshot), the cluster size is
larger than 512, and the image is larger than 2G in size, then our
choice of sector_step causes problems.  Since it is not cluster
aligned, but qcow2_discard_clusters() silently ignores an unaligned
head or tail, we are leaving clusters allocated.

Enhance the testsuite to expose the flaw, and patch the problem by
ensuring our step size is aligned.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c
tests/qemu-iotests/097
tests/qemu-iotests/097.out