qcow2: Respect new_block in alloc_refcount_block()
authorMax Reitz <mreitz@redhat.com>
Tue, 10 Feb 2015 20:02:31 +0000 (15:02 -0500)
committerMax Reitz <mreitz@redhat.com>
Mon, 16 Mar 2015 16:10:30 +0000 (12:10 -0400)
commit14a58a4e0c2e98a7d9232e1c229a531ca231133b
treeda3f084b64c003b0c87a915cdd94980cb5742a11
parent2867ce4ab86c77579e94c6bb2b6e44ddfcf67f5d
qcow2: Respect new_block in alloc_refcount_block()

When choosing a new place for the refcount table, alloc_refcount_block()
tries to infer the number of clusters used so far from its argument
cluster_index (which comes from the idea that if any cluster with an
index greater than cluster_index was in use, the refcount table would
have to be big enough already to describe cluster_index).

However, there is a cluster that may be at or after cluster_index, and
which is not covered by the refcount structures, and that is the new
refcount block new_block. Therefore, it should be taken into account for
the blocks_used calculation.

Also, because new_block already describes (or is intended to describe)
cluster_index, we may not put the new refcount structures there.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 1423598552-24301-2-git-send-email-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2-refcount.c