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: Kevin Wolf
Subject: Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters
Date: Mon, 24 Feb 2014 10:46:02 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 22.02.2014 um 01:01 hat Eric Blake geschrieben:
> 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?

No, that doesn't work because when you have multiple virtual clusters
pointing to the same physical cluster in a single snapshot, you can't
guarantee any more that QCOW_OFLAG_COPIED is set correctly.

Ironically, I guess you could still do it in v3 when you set the dirty
flag of lazy refcounting, but we don't have that in v2 either...

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

Right, that too.

Kevin

Attachment: pgpUHC0EoAGTK.pgp
Description: PGP signature


reply via email to

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