]> git.proxmox.com Git - qemu.git/commit
qcow2: Fix avail_sectors in cluster allocation code
authorKevin Wolf <kwolf@redhat.com>
Tue, 22 May 2012 15:01:20 +0000 (17:01 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 15 Jun 2012 12:03:43 +0000 (14:03 +0200)
commitb7ab0fea37c15ca9e249c42c46f5c48fd1a0943c
treefe889a84ce2b46db7ab45dd2a2558c863ea64d0e
parentcdba7fee1daa8865bac2d69da288171fe7c21aae
qcow2: Fix avail_sectors in cluster allocation code

avail_sectors should really be the number of sectors from the start of
the allocation, not from the start of the write request.

We're lucky enough that this mistake didn't cause any real bug.
avail_sectors is only used in the intialiser of QCowL2Meta:

  .nb_available   = MIN(requested_sectors, avail_sectors),

m->nb_available in turn is only used for COW at the end of the
allocation. A COW occurs only if the request wasn't cluster aligned,
which in turn would imply that requested_sectors was less than
avail_sectors (both in the original and in the fixed version). In this
case avail_sectors is ignored and therefore the mistake doesn't cause
any misbehaviour.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cluster.c