From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c921P-0004R9-5i for qemu-devel@nongnu.org; Mon, 21 Nov 2016 22:45:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c921N-0002jX-PH for qemu-devel@nongnu.org; Mon, 21 Nov 2016 22:45:27 -0500 References: <20161121012439.2394-1-w90p710@gmail.com> <20161121113436.GA5876@noname.redhat.com> From: wyang Message-ID: <5833BF4A.8030102@gmail.com> Date: Tue, 22 Nov 2016 11:45:14 +0800 MIME-Version: 1.0 In-Reply-To: <20161121113436.GA5876@noname.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: Kevin Wolf Cc: jcody@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org On 2016年11月21日 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. 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 and I tried to qemu-img map --output json xxxx.img, as you can see, the field of data always is true. when I migrated it with --copy-storage-all, I get non-spareness image. I tried to read qcow2_co_get_blcok_status, but I did not find anything issue, if you can give a hint on the case, i fix it.:-) # qemu-img map --output json 20G.img [{ "start": 0, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 327680}, { "start": 536870912, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 537264128}, { "start": 1073741824, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 1074200576}, { "start": 1610612736, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 1611137024}, { "start": 2147483648, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 2148139008}, { "start": 2684354560, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 2685075456}, { "start": 3221225472, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 3222011904}, { "start": 3758096384, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 3758948352}, { "start": 4294967296, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 4295950336}, { "start": 4831838208, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 4832886784}, { "start": 5368709120, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 5369823232}, { "start": 5905580032, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 5906759680}, { "start": 6442450944, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 6443761664}, { "start": 6979321856, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 6980698112}, { "start": 7516192768, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 7517634560}, { "start": 8053063680, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 8054571008}, { "start": 8589934592, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 8591572992}, { "start": 9126805504, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 9128509440}, { "start": 9663676416, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 9665445888}, { "start": 10200547328, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 10202382336}, { "start": 10737418240, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 10739384320}, { "start": 11274289152, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 11276320768}, { "start": 11811160064, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 11813257216}, { "start": 12348030976, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 12350193664}, { "start": 12884901888, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 12887195648}, { "start": 13421772800, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 13424132096}, { "start": 13958643712, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 13961068544}, { "start": 14495514624, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 14498004992}, { "start": 15032385536, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 15035006976}, { "start": 15569256448, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 15571943424}, { "start": 16106127360, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 16108879872}, { "start": 16642998272, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 16645816320}, { "start": 17179869184, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 17182818304}, { "start": 17716740096, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 17719754752}, { "start": 18253611008, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 18256691200}, { "start": 18790481920, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 18793627648}, { "start": 19327352832, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 19330629632}, { "start": 19864223744, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 19867566080}, { "start": 20401094656, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 20404502528}, { "start": 20937965568, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 20941438976}] > > 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 in > 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 overhead. > > If you really want to detect zeroes, create the target block driver node > manually (with detect-zeroes=on) and use the blockdev-mirror QMP command > 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. Thanks Wei > > Kevin >