From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rul5J-0007CM-MV for qemu-devel@nongnu.org; Tue, 07 Feb 2012 08:27:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rul5D-0005Dp-Q4 for qemu-devel@nongnu.org; Tue, 07 Feb 2012 08:27:49 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:33966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rul5D-0005DE-C8 for qemu-devel@nongnu.org; Tue, 07 Feb 2012 08:27:43 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2012 13:27:40 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q17DRbug2949312 for ; Tue, 7 Feb 2012 13:27:37 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q17DRbQK005314 for ; Tue, 7 Feb 2012 06:27:37 -0700 From: Stefan Hajnoczi Date: Tue, 7 Feb 2012 13:27:23 +0000 Message-Id: <1328621250-8130-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v5 0/6] block: zero writes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This series adds an interface for efficient writes when data contains all zeros. It also takes advantage of this new interface by extending the copy-on-read feature to perform zero-detection. The details of efficient zero representations depend on the image format. This series includes a patch for the QED image format to write special "zero clusters" that keep the image file compact. In the future qcow2v3 could also support an efficient zero representation. The new BlockDriver interface is called .bdrv_co_write_zeroes() and is optional. If the interface is not implemented by a BlockDriver then a regular .bdrv_co_writev() operation will be performed. The public interface is called bdrv_co_write_zeroes() and can be tested via the new qemu-io write -z option. Copy-on-read is extended to detect zeroes and invoke the .bdrv_co_write_zeroes() interface when possible. As a result we avoid bloating the image file if the backing file contains zeroes. My motivation for this feature is efficient image streaming. The destination file must stay compact even when copying zeroes from the source file. We now only do zero detection for copy-on-read requests, whereas previous revisions of this patch series scanned all write requests for zeroes. The old behavior wasted CPU cycles in most cases but we could add a feature to explicitly scan guest writes for zeroes in the future, if desired. v5: * assert length constraint in buffer_is_zero() [Kevin] * explain why bdrv_co_write_zeroes() is not suitable for huge requests [Kevin] v3: * Rebased on image streaming series v2: * Introduce .bdrv_co_write_zeroes() [Kevin] * Perform zero detection only on copy-on-read requests [Kevin] Stefan Hajnoczi (6): cutils: extract buffer_is_zero() from qemu-img.c block: add .bdrv_co_write_zeroes() interface block: perform zero-detection during copy-on-read qed: replace is_write with flags field qed: add .bdrv_co_write_zeroes() support qemu-io: add write -z option for bdrv_co_write_zeroes block.c | 67 ++++++++++++++++++++++++++---- block.h | 8 ++++ block/qed.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++------- block/qed.h | 7 +++- block_int.h | 8 ++++ cutils.c | 35 ++++++++++++++++ qemu-common.h | 2 + qemu-img.c | 46 +++------------------ qemu-io.c | 77 +++++++++++++++++++++++++++++++---- trace-events | 3 +- 10 files changed, 305 insertions(+), 73 deletions(-) -- 1.7.8.3