[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
pgpUHC0EoAGTK.pgp
Description: PGP signature
- [Qemu-devel] [PULL 00/54] Block patches, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 02/54] block: Fix bdrv_is_first_non_filter(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 03/54] block: Change BDS parameter of bdrv_open() to **, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 05/54] block: Make bdrv_file_open() static, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 04/54] block: Add reference parameter to bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 06/54] block: Reuse reference handling from bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 07/54] block: Remove bdrv_new() from bdrv_file_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 08/54] block: Handle bs->options in bdrv_open() only, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 09/54] block: Reuse success path from bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 10/54] block: Remove bdrv_open_image()'s force_raw option, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 11/54] nbd: produce a better error if neither host nor port is passed, Kevin Wolf, 2014/02/21