qcow2: Make distinction between zero cluster types obvious
commitfdfab37dfeffefbd4533b4158055c9b82d7c3e69
authorEric Blake <eblake@redhat.com>
Sun, 7 May 2017 00:05:46 +0000 (6 19:05 -0500)
committerMax Reitz <mreitz@redhat.com>
Thu, 11 May 2017 12:28:07 +0000 (11 14:28 +0200)
treed02d0737168042286445a6d6187eb8fa662ed557
parent3ef9521893c41638148d4452ee4da75fd8ef71a9
qcow2: Make distinction between zero cluster types obvious

Treat plain zero clusters differently from allocated ones, so that
we can simplify the logic of checking whether an offset is present.
Do this by splitting QCOW2_CLUSTER_ZERO into two new enums,
QCOW2_CLUSTER_ZERO_PLAIN and QCOW2_CLUSTER_ZERO_ALLOC.

I tried to arrange the enum so that we could use
'ret <= QCOW2_CLUSTER_ZERO_PLAIN' for all unallocated types, and
'ret >= QCOW2_CLUSTER_ZERO_ALLOC' for allocated types, although
I didn't actually end up taking advantage of the layout.

In many cases, this leads to simpler code, by properly combining
cases (sometimes, both zero types pair together, other times,
plain zero is more like unallocated while allocated zero is more
like normal).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 20170507000552.20847-7-eblake@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2-cluster.c
block/qcow2-refcount.c
block/qcow2.c
block/qcow2.h
tests/qemu-iotests/060.out