From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9817-0007yc-93 for qemu-devel@nongnu.org; Tue, 22 Nov 2016 05:09:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9813-0001gf-6P for qemu-devel@nongnu.org; Tue, 22 Nov 2016 05:09:33 -0500 Date: Tue, 22 Nov 2016 11:09:15 +0100 From: Kevin Wolf Message-ID: <20161122100915.GA5615@noname.redhat.com> References: <20161121012439.2394-1-w90p710@gmail.com> <20161121113436.GA5876@noname.redhat.com> <5833BF4A.8030102@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5833BF4A.8030102@gmail.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block/mirror: enable detect zeroes when driving mirror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: wyang Cc: jcody@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Am 22.11.2016 um 04:45 hat wyang geschrieben: > On 2016=E5=B9=B411=E6=9C=8821=E6=97=A5 19:34, Kevin Wolf wrote: > >Am 21.11.2016 um 02:24 hat Yang Wei geschrieben: > >>In order to preserve sparse disk image, detect_zeroes > >>should also be enabled when bdrv_get_block_status_above() > >>returns BDRV_BLOCK_DATA > >> > >>Signed-off-by: Yang Wei > >Just preserving sparseness is exactly why bdrv_get_block_status_above(= ) > >is checked, and this happens always. >=20 > I have a sparse qcow2 image(virtual size: 20G disk size: 12G), > # qemu-img info 20G.img > image: 20G.img > file format: qcow2 > virtual size: 20G (21474836480 bytes) > disk size: 12G > cluster_size: 65536 > Format specific information: > compat: 1.1 > lazy refcounts: false > refcount bits: 16 > corrupt: false >=20 > and I tried to qemu-img map --output json xxxx.img, as you can see, > the field of data always is true. Did you use metadata preallocation? If so, you explicitly requested all clusters to be allocated. > >detect_zeroes does not preserve sparseness, but detect zeroes in parts > >of the source image that are not sparse, and make them sparse in the > >target image. This means that it has higher overhead (because all > >sectors need to be processed before copying them) and doesn't result i= n > >an exact copy. There may be cases where this is wanted, but in the > >common case, it's probably not the right mode of operation. > To be frank, customers are more concerned about sparseness than overhea= d. All generalisations are wrong. We could be talking about the majority of users (the QEMU project doesn't have customers), but even then I doubt you're right, especially when using preallocation which is a tool for giving up sparseness in favour of improved performance of the first write to a cluster. > >If you really want to detect zeroes, create the target block driver no= de > >manually (with detect-zeroes=3Don) and use the blockdev-mirror QMP com= mand > >to mirror to it. > the target block is created by **bdrv_img_create** and opened by > **bdrv_open** inside qmp_drive_mirror, it also mean than we only > enable detect-zeroes while > its opened, i don't find qmp cmd to only enable it, if I understand > correctly. That's why I said you use blockdev-mirror instead drive-mirror. Kevin