[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 05/34] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in
From: |
Max Reitz |
Subject: |
Re: [PATCH v9 05/34] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied() |
Date: |
Tue, 30 Jun 2020 12:38:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 28.06.20 13:02, Alberto Garcia wrote:
> When writing to a qcow2 file there are two functions that take a
> virtual offset and return a host offset, possibly allocating new
> clusters if necessary:
>
> - handle_copied() looks for normal data clusters that are already
> allocated and have a reference count of 1. In those clusters we
> can simply write the data and there is no need to perform any
> copy-on-write.
>
> - handle_alloc() looks for clusters that do need copy-on-write,
> either because they haven't been allocated yet, because their
> reference count is != 1 or because they are ZERO_ALLOC clusters.
>
> The ZERO_ALLOC case is a bit special because those are clusters that
> are already allocated and they could perfectly be dealt with in
> handle_copied() (as long as copy-on-write is performed when required).
>
> In fact, there is extra code specifically for them in handle_alloc()
> that tries to reuse the existing allocation if possible and frees them
> otherwise.
>
> This patch changes the handling of ZERO_ALLOC clusters so the
> semantics of these two functions are now like this:
>
> - handle_copied() looks for clusters that are already allocated and
> which we can overwrite (NORMAL and ZERO_ALLOC clusters with a
> reference count of 1).
>
> - handle_alloc() looks for clusters for which we need a new
> allocation (all other cases).
>
> One important difference after this change is that clusters found
> in handle_copied() may now require copy-on-write, but this will be
> necessary anyway once we add support for subclusters.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
> block/qcow2-cluster.c | 256 +++++++++++++++++++++++-------------------
> 1 file changed, 141 insertions(+), 115 deletions(-)
Reviewed-by: Max Reitz <mreitz@redhat.com>
signature.asc
Description: OpenPGP digital signature
- [PATCH v9 10/34] qcow2: Add offset_to_sc_index(), (continued)
- [PATCH v9 10/34] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2020/06/28
- [PATCH v9 07/34] qcow2: Document the Extended L2 Entries feature, Alberto Garcia, 2020/06/28
- [PATCH v9 08/34] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2020/06/28
- [PATCH v9 26/34] qcow2: Clear the L2 bitmap when allocating a compressed cluster, Alberto Garcia, 2020/06/28
- [PATCH v9 03/34] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2020/06/28
- [PATCH v9 06/34] qcow2: Add get_l2_entry() and set_l2_entry(), Alberto Garcia, 2020/06/28
- [PATCH v9 02/34] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/06/28
- [PATCH v9 05/34] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2020/06/28
- Re: [PATCH v9 05/34] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(),
Max Reitz <=
- [PATCH v9 04/34] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), Alberto Garcia, 2020/06/28
- [PATCH v9 13/34] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(), Alberto Garcia, 2020/06/28
- [PATCH v9 24/34] qcow2: Add subcluster support to check_refcounts_l2(), Alberto Garcia, 2020/06/28
- [PATCH v9 19/34] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC, Alberto Garcia, 2020/06/28
- [PATCH v9 09/34] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2020/06/28
- [PATCH v9 16/34] qcow2: Add qcow2_cluster_is_allocated(), Alberto Garcia, 2020/06/28
- [PATCH v9 11/34] qcow2: Add offset_into_subcluster() and size_to_subclusters(), Alberto Garcia, 2020/06/28
- [PATCH v9 29/34] qcow2: Add subcluster support to qcow2_measure(), Alberto Garcia, 2020/06/28
- [PATCH v9 22/34] qcow2: Add subcluster support to zero_in_l2_slice(), Alberto Garcia, 2020/06/28
- [PATCH v9 25/34] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2020/06/28