On 12/22/19 5:36 AM, Alberto Garcia wrote:
Subcluster allocation in qcow2 is implemented by extending the
existing L2 table entries and adding additional information to
indicate the allocation status of each subcluster.

This patch documents the changes to the qcow2 format and how they
affect the calculation of the L2 cache size.

Signed-off-by: Alberto Garcia <be...@igalia.com>
---

@@ -437,7 +445,7 @@ cannot be relaxed without an incompatible layout change).
  Given an offset into the virtual disk, the offset into the image file can be
  obtained as follows:
- l2_entries = (cluster_size / sizeof(uint64_t))
+    l2_entries = (cluster_size / sizeof(uint64_t))        [*]
l2_index = (offset / cluster_size) % l2_entries
      l1_index = (offset / cluster_size) / l2_entries
@@ -447,6 +455,8 @@ obtained as follows:
return cluster_offset + (offset % cluster_size) + [*] this changes if Extended L2 Entries are enabled, see next section

+The size of an extended L2 entry is 128 bits so the number of entries per table
+is calculated using this formula:
+
+    l2_entries = (cluster_size / (2 * sizeof(uint64_t)))

Is it worth unifying these statements by writing:

l2_entries = (cluster_size / ((1 + extended_l2) * sizeof(uint64_t)))

or is that too confusing?

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Reply via email to