diff options
author | Christoph Hellwig <hch@lst.de> | 2010-12-16 19:36:31 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-12-17 16:11:03 +0100 |
commit | d54f28d2875d7743267fe094b987042c8d6f8da5 (patch) | |
tree | 3869081b39a96da24bff96e06099794960dd9ccf /block.c | |
parent | 3f0854e8b659c2b7087f04d4f0e4bf3d123b8048 (diff) | |
download | qemu-d54f28d2875d7743267fe094b987042c8d6f8da5.tar.gz qemu-d54f28d2875d7743267fe094b987042c8d6f8da5.tar.bz2 qemu-d54f28d2875d7743267fe094b987042c8d6f8da5.zip |
block: add discard support
Add a new bdrv_discard method to free blocks in a mapping image, and a new
drive property to set the granularity for these discard. If no discard
granularity support is set discard support is disabled.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1515,6 +1515,17 @@ int bdrv_has_zero_init(BlockDriverState *bs) return 1; } +int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) +{ + if (!bs->drv) { + return -ENOMEDIUM; + } + if (!bs->drv->bdrv_discard) { + return 0; + } + return bs->drv->bdrv_discard(bs, sector_num, nb_sectors); +} + /* * Returns true iff the specified sector is present in the disk image. Drivers * not implementing the functionality are assumed to not support backing files, |