qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 0/3] block: zero write detection


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 0/3] block: zero write detection
Date: Tue, 11 Oct 2011 15:46:28 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0

Am 07.10.2011 17:49, schrieb Stefan Hajnoczi:
> Image streaming copies data from the backing file into the image file.  It is
> important to represent zero regions from the backing file efficiently during
> streaming, otherwise the image file grows to the full virtual disk size and
> loses sparseness.
> 
> There are two ways to implement zero write detection, they are subtly 
> different:
> 
> 1. Allow image formats to provide efficient representations for zero regions.
>    QED does this with "zero clusters" and it has been discussed for qcow2v3.
> 
> 2. During streaming, check for zeroes and skip writing to the image file when
>    zeroes are detected.
> 
> However, there are some disadvantages to #2 because it leaves unallocated 
> holes
> in the image file.  If image streaming is aborted before it completes then it
> will be necessary to reread all unallocated clusters from the backing file 
> upon
> resuming image streaming.  Potentionally worse is that a backing file over a
> slow remote connection will have the zero regions fetched again and again if
> the guest accesses them.  #1 avoids these problems because the image file
> contains information on which regions are zeroes and do not need to be
> refetched.
> 
> This patch series implements #1 with the existing QED zero cluster feature.  
> In
> the future we can add qcow2v3 zero clusters too.  We can also implement #2
> directly in the image streaming code as a fallback when the BlockDriver does
> not support zero detection #1 itself.  That way we get the best possible zero
> write detection, depending on the image format.
> 
> Here is a qemu-iotest to verify that zero write detection is working:
> http://repo.or.cz/w/qemu-iotests/stefanha.git/commitdiff/226949695eef51bdcdea3e6ce3d7e5a863427f37
> 
> Stefan Hajnoczi (3):
>   block: add zero write detection interface
>   qed: add zero write detection support
>   qemu-io: add zero write detection option
> 
>  block.c     |   16 +++++++++++
>  block.h     |    2 +
>  block/qed.c |   81 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++------
>  block_int.h |   13 +++++++++
>  qemu-io.c   |   35 ++++++++++++++++++++-----
>  5 files changed, 132 insertions(+), 15 deletions(-)

It's good to have an option to detect zero writes and turn them into
zero clusters, but it's something that introduces some overhead and
probably won't be suitable as a default.

I think what we really want to have for image streaming is an API that
explicitly writes zeros and doesn't have to look at the whole buffer (or
actually doesn't even get a buffer).

The complementing feature on the source image side would be a way to let
the source image format signal that it would read only zeros (e.g.
because the cluster wasn't allocated or a zero cluster).

This would avoid memsetting a full buffer of zeros in bdrv_co_readv,
just to be able to pass this buffer to bdrv_co_writev, where the driver
loops over the whole buffer again in order to verify that it really only
contains zeros.

If you handle it at this generic block layer level, you could also treat
streaming writes differently than guest writes. (You would probably want
to search buffers by default for the former, but not for the latter)

Kevin



reply via email to

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