qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded cluster


From: Eric Blake
Subject: Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters
Date: Fri, 21 Feb 2014 17:01:05 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 02/21/2014 03:11 PM, Kevin Wolf wrote:
> Instead of making the backing file contents visible again after a discard
> request, set the zero flag if possible (i.e. on version >= 3).
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> ---
>  block/qcow2-cluster.c  | 22 ++++++++++++++++++++--
>  tests/qemu-iotests/046 | 18 ++++++++++++++----
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index c57f39d..36c1bed 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -1367,13 +1367,31 @@ static int discard_single_l2(BlockDriverState *bs, 
> uint64_t offset,
>          uint64_t old_offset;
>  
>          old_offset = be64_to_cpu(l2_table[l2_index + i]);
> -        if ((old_offset & L2E_OFFSET_MASK) == 0) {
> +
> +        /*
> +         * Make sure that a discarded area reads back as zeroes for v3 images
> +         * (we cannot do it for v2 without actually writing a zero-filled
> +         * buffer). We can skip the operation if the cluster is already 
> marked
> +         * as zero, or if it's unallocated and we don't have a backing file.
> +         *

Possible idea for a followup:

Is it possible with v2 images to write a single sector/cluster with all
0s, and to make all other writes of all-0 data bump the reference count
of the magic known-zero cluster, so that we are at least conserving disk
space by heavily reusing the known cluster?

Then again, we may be reaching the point where no one cares about v2
images as much.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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