qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/4] qcow2: Reuse preallocated zero clusters


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 2/4] qcow2: Reuse preallocated zero clusters
Date: Wed, 3 May 2017 19:58:06 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 05/03/2017 06:11 PM, Max Reitz wrote:
> Instead of just freeing preallocated zero clusters and completely
> allocating them from scratch, reuse them.
> 
> We cannot do this in handle_copied(), however, since this is a COW
> operation. Therefore, we have to add the new logic to handle_alloc() and
> simply return the existing offset if it exists. The only catch is that
> we have to convince qcow2_alloc_cluster_link_l2() not to free the old
> clusters (because we have reused them).
> 
> Reported-by: Eric Blake <address@hidden>
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  block/qcow2.h         |  3 ++
>  block/qcow2-cluster.c | 80 
> +++++++++++++++++++++++++++++++++++----------------
>  2 files changed, 59 insertions(+), 24 deletions(-)
> 

>  
> -    assert(qcow2_get_cluster_type(first_entry) == QCOW2_CLUSTER_NORMAL);
> +    /* must be allocated */
> +    first_cluster_type = qcow2_get_cluster_type(first_entry);
> +    assert(first_cluster_type == QCOW2_CLUSTER_NORMAL ||
> +           (first_cluster_type == QCOW2_CLUSTER_ZERO &&
> +            (first_entry & L2E_OFFSET_MASK) != 0));

I wonder if we should have separate QCOW2_CLUSTER_ZERO_PLAIN and
QCOW2_CLUSTER_ZERO_ALLOCATED, so we don't have to keep checking
first_entry & L2E_OFFSET_MASK.  But I think that can be a separate
followup if we want it.


Reviewed-by: Eric Blake <address@hidden>

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]