qcow2: Do not perform potentially damaging repairs
commitf307b2558f61e068ce514f2dde2cad74c62036d6
authorMax Reitz <mreitz@redhat.com>
Wed, 22 Oct 2014 12:09:39 +0000 (22 14:09 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 23 Oct 2014 13:34:01 +0000 (23 15:34 +0200)
treea507b7ba20578c1af38cc4778b0cdf7b797c0e41
parent001c158defb65e88e6c50c85d6f20501f7149ddd
qcow2: Do not perform potentially damaging repairs

If a referenced cluster has a refcount of 0, increasing its refcount may
result in clusters being allocated for the refcount structures. This may
overwrite the referenced cluster, therefore we cannot simply increase
the refcount then.

In such cases, we can either try to replicate all the refcount
operations solely for the check operation, basing the allocations on the
in-memory refcount table; or we can simply rebuild the whole refcount
structure based on the in-memory refcount table. Since the latter will
be much easier, do that.

To prepare for this, introduce a "rebuild" boolean which should be set
to true whenever a fix is rather dangerous or too complicated using the
current refcount structures. Another example for this is refcount blocks
being referenced more than once.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-refcount.c