[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 20/32] qcow2: Add subcluster support to calculate_l2_meta(
From: |
Eric Blake |
Subject: |
Re: [PATCH v7 20/32] qcow2: Add subcluster support to calculate_l2_meta() |
Date: |
Wed, 27 May 2020 10:57:57 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 5/25/20 1:08 PM, Alberto Garcia wrote:
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.
Quite the mouthful! But the description looks correct, and the code
appears to match it.
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 <address@hidden>
---
block/qcow2-cluster.c | 163 +++++++++++++++++++++++++++++++++---------
1 file changed, 131 insertions(+), 32 deletions(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH v7 03/32] qcow2: Add calculate_l2_meta(), (continued)
- [PATCH v7 03/32] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2020/05/25
- [PATCH v7 26/32] qcow2: Clear the L2 bitmap when allocating a compressed cluster, Alberto Garcia, 2020/05/25
- [PATCH v7 21/32] qcow2: Add subcluster support to qcow2_get_host_offset(), Alberto Garcia, 2020/05/25
- [PATCH v7 32/32] iotests: Add tests for qcow2 images with extended L2 entries, Alberto Garcia, 2020/05/25
- [PATCH v7 17/32] qcow2: Add cluster type parameter to qcow2_get_host_offset(), Alberto Garcia, 2020/05/25
- [PATCH v7 02/32] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/05/25
- [PATCH v7 05/32] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2020/05/25
- [PATCH v7 12/32] qcow2: Add l2_entry_size(), Alberto Garcia, 2020/05/25
- [PATCH v7 30/32] qcow2: Add the 'extended_l2' option and the QCOW2_INCOMPAT_EXTL2 bit, Alberto Garcia, 2020/05/25
- [PATCH v7 20/32] qcow2: Add subcluster support to calculate_l2_meta(), Alberto Garcia, 2020/05/25
- Re: [PATCH v7 20/32] qcow2: Add subcluster support to calculate_l2_meta(),
Eric Blake <=
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/25
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26
- Re: [PATCH v7 00/32] Add subcluster allocation to qcow2, no-reply, 2020/05/26