From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdPNE-0004rx-1l for qemu-devel@nongnu.org; Wed, 21 Dec 2011 11:50:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RdPND-0003hA-3T for qemu-devel@nongnu.org; Wed, 21 Dec 2011 11:50:36 -0500 Received: from verein.lst.de ([213.95.11.211]:48685 helo=newverein.lst.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdPNC-0003gh-TQ for qemu-devel@nongnu.org; Wed, 21 Dec 2011 11:50:35 -0500 Date: Wed, 21 Dec 2011 17:50:32 +0100 From: Christoph Hellwig Message-ID: <20111221165032.GA27022@lst.de> References: <1324483240-31726-1-git-send-email-stefanha@linux.vnet.ibm.com> <1324483240-31726-3-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1324483240-31726-3-git-send-email-stefanha@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v3 2/6] block: add .bdrv_co_write_zeroes() interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Marcelo Tosatti , qemu-devel@nongnu.org On Wed, Dec 21, 2011 at 04:00:36PM +0000, Stefan Hajnoczi wrote: > The ability to zero regions of an image file is a useful primitive for > higher-level features such as image streaming or zero write detection. > > Image formats may support an optimized metadata representation instead > of writing zeroes into the image file. This allows zero writes to be > potentially faster than regular write operations and also preserve > sparseness of the image file. > > The .bdrv_co_write_zeroes() interface should be implemented by block > drivers that wish to provide efficient zeroing. > > Note that this operation is different from the discard operation, which > may leave the contents of the region indeterminate. That means > discarded blocks are not guaranteed to contain zeroes and may contain > junk data instead. Most real life discard operations zero the data, and both the ATA and SCSI spec allow the device to set a bit which gurantees this behaviour. I think we also should make these one interface, and if the caller needs it to actually zero out the discarded blocks it should check if the discard implementation guarantees that.