mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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>
This commit is contained in:
parent
61d9d6b091
commit
bb8bf76fb1
4 changed files with 24 additions and 1 deletions
11
block.c
11
block.c
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue