On Wed, Dec 21, 2011 at 05:50:32PM +0100, Christoph Hellwig wrote:
> 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.

Okay, I see how that could work but still need to look into the details
of how to combine the two and check the zero/indeterminate bit coming
from ATA/SCSI.

Stefan


Reply via email to