diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-02-07 13:27:25 +0000 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-02-09 16:17:50 +0100 |
commit | f08f2ddae078e8a7683f8b16da8e0cc3029c7b89 (patch) | |
tree | bfb375876998a1c425ce6bb018dcd923118b7aea /block_int.h | |
parent | 1a6d39fd71ddf90c5b76026cac4d5ff51fbaf8d8 (diff) |
block: add .bdrv_co_write_zeroes() interface
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.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block_int.h')
-rw-r--r-- | block_int.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/block_int.h b/block_int.h index 7be2988ca7..7946cf66a1 100644 --- a/block_int.h +++ b/block_int.h @@ -131,6 +131,14 @@ struct BlockDriver { int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); + /* + * Efficiently zero a region of the disk image. Typically an image format + * would use a compact metadata representation to implement this. This + * function pointer may be NULL and .bdrv_co_writev() will be called + * instead. + */ + int coroutine_fn (*bdrv_co_write_zeroes)(BlockDriverState *bs, + int64_t sector_num, int nb_sectors); int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs, |