From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6Go-0003Gy-C5 for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:34:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT6Gi-0007vT-RI for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:34:26 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:33720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6Gi-0007vN-KM for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:34:20 -0400 Received: by mail-wi0-f181.google.com with SMTP id ex4so4408371wid.2 for ; Mon, 07 Oct 2013 01:34:19 -0700 (PDT) Date: Mon, 7 Oct 2013 10:34:15 +0200 From: Stefan Hajnoczi Message-ID: <20131007083415.GD6254@stefanha-thinkpad.redhat.com> References: <1380029714-5239-1-git-send-email-pl@kamp.de> <1380029714-5239-14-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1380029714-5239-14-git-send-email-pl@kamp.de> Subject: Re: [Qemu-devel] [PATCHv3 13/20] block: introduce bdrv_zeroize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com, ronniesahlberg@gmail.com On Tue, Sep 24, 2013 at 03:35:07PM +0200, Peter Lieven wrote: > this patch adds a call to completely zero out a block device. > the operation is sped up by checking the block status and > only writing zeroes to the device if they currently do not > return zeroes. optionally the zero writing can be sped up > by setting the flag BDRV_REQ_MAY_UNMAP to emulate the zero > write by unmapping if the driver supports it. > > Signed-off-by: Peter Lieven > --- > block.c | 37 +++++++++++++++++++++++++++++++++++++ > include/block/block.h | 1 + > 2 files changed, 38 insertions(+) > > diff --git a/block.c b/block.c > index 784e545..66b9eae 100644 > --- a/block.c > +++ b/block.c > @@ -2398,6 +2398,43 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, > BDRV_REQ_ZERO_WRITE | flags); > } > > +/* > + * Completely zero out a block device with the help of bdrv_write_zeroes. > + * The operation is sped up by checking the block status and only writing > + * zeroes to the device if they currently do not return zeroes. Optional > + * flags are passed through to bdrv_write_zeroes (e.g. BDRV_REQ_MAY_UNMAP). > + * > + * Returns < 0 on error, 0 on success. For error codes see bdrv_write(). > + */ > +int bdrv_zeroize(BlockDriverState *bs, BdrvRequestFlags flags) BlockDriver->bdrv_make_empty() implements zeroing the entire disk for image formats. Please extend that function prototype instead of adding a new interface. Stefan