diff options
author | Alberto Garcia <berto@igalia.com> | 2020-07-10 18:13:02 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2020-08-25 08:33:20 +0200 |
commit | d53ec3d8d8e12d5a7c7f48347be450af56040b1a (patch) | |
tree | 708f2c5641a05e785f005faff3190681e9899f70 /scripts/clean-includes | |
parent | 97490a143ee7db264ae91623e3c1a4762835911b (diff) | |
download | qemu-d53ec3d8d8e12d5a7c7f48347be450af56040b1a.zip qemu-d53ec3d8d8e12d5a7c7f48347be450af56040b1a.tar.gz qemu-d53ec3d8d8e12d5a7c7f48347be450af56040b1a.tar.bz2 |
qcow2: Add subcluster support to calculate_l2_meta()
If an image has subclusters then there are more copy-on-write
scenarios that we need to consider. Let's say we have a write request
from the middle of subcluster #3 until the end of the cluster:
1) If we are writing to a newly allocated cluster then we need
copy-on-write. The previous contents of subclusters #0 to #3 must
be copied to the new cluster. We can optimize this process by
skipping all leading unallocated or zero subclusters (the status of
those skipped subclusters will be reflected in the new L2 bitmap).
2) If we are overwriting an existing cluster:
2.1) If subcluster #3 is unallocated or has the all-zeroes bit set
then we need copy-on-write (on subcluster #3 only).
2.2) If subcluster #3 was already allocated then there is no need
for any copy-on-write. However we still need to update the L2
bitmap to reflect possible changes in the allocation status of
subclusters #4 to #31. Because of this, this function checks
if all the overwritten subclusters are already allocated and
in this case it returns without creating a new QCowL2Meta
structure.
After all these changes l2meta_cow_start() and l2meta_cow_end()
are not necessarily cluster-aligned anymore. We need to update the
calculation of old_start and old_end in handle_dependencies() to
guarantee that no two requests try to write on the same cluster.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <4292dd56e4446d386a2fe307311737a711c00708.1594396418.git.berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'scripts/clean-includes')
0 files changed, 0 insertions, 0 deletions