OSDN Git Service

qcow2: Update l2_load() to support L2 slices
authorAlberto Garcia <berto@igalia.com>
Mon, 5 Feb 2018 14:33:15 +0000 (16:33 +0200)
committerMax Reitz <mreitz@redhat.com>
Tue, 13 Feb 2018 15:59:59 +0000 (16:59 +0100)
commite2b5713eb9a8545e00eaeb5350069ef40c6cc49a
treea54b556b5db9c20d427dca518ccd10d8ac4a9c57
parent8f8181757771f252106efe2d6e833aabf0b64d01
qcow2: Update l2_load() to support L2 slices

Each entry in the qcow2 L2 cache stores a full L2 table (which uses a
complete cluster in the qcow2 image). A cluster is usually too large
to be used efficiently as the size for a cache entry, so we want to
decouple both values by allowing smaller cache entries. Therefore the
qcow2 L2 cache will no longer return full L2 tables but slices
instead.

This patch updates l2_load() so it can handle L2 slices correctly.
Apart from the offset of the L2 table (which we already had) we also
need the guest offset in order to calculate which one of the slices
we need.

An L2 slice has currently the same size as an L2 table (one cluster),
so for now this function will load exactly the same data as before.

This patch also removes a stale comment about the return value being
a pointer to the L2 table. This function returns an error code since
55c17e9821c474d5fcdebdc82ed2fc096777d611.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: b830aa1fc5b6f8e3cb331d006853fe22facca847.1517840877.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2-cluster.c