aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-07-15 17:22:58 -0600
committerStefan Hajnoczi <stefanha@redhat.com>2016-07-20 14:11:55 +0100
commit47a5486d598e0cfef6c87c5f44b85955a5f2c4ff (patch)
treef9829a55d7484cd58245d34d2cab210d27a9df1b /block
parent4da444a0bb5b6a7563a785f027402e5af4bd53aa (diff)
downloadqemu-47a5486d598e0cfef6c87c5f44b85955a5f2c4ff.zip
qemu-47a5486d598e0cfef6c87c5f44b85955a5f2c4ff.tar.gz
qemu-47a5486d598e0cfef6c87c5f44b85955a5f2c4ff.tar.bz2
block: Add .bdrv_co_pdiscard() driver callback
There's enough drivers with a sector-based callback that it will be easier to switch one at a time. This patch adds a byte-based callback, and then after all drivers are swapped, we'll drop the sector-based callback. [checkpatch doesn't like the space after coroutine_fn in block_int.h, but it's consistent with the rest of the file] Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1468624988-423-10-git-send-email-eblake@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/io.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block/io.c b/block/io.c
index 5c759fa..5ba0195 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2423,7 +2423,8 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
return 0;
}
- if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_pdiscard) {
+ if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_co_pdiscard &&
+ !bs->drv->bdrv_aio_pdiscard) {
return 0;
}
@@ -2455,7 +2456,9 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
int ret;
int num = MIN(count, max_pdiscard);
- if (bs->drv->bdrv_co_discard) {
+ if (bs->drv->bdrv_co_pdiscard) {
+ ret = bs->drv->bdrv_co_pdiscard(bs, offset, num);
+ } else if (bs->drv->bdrv_co_discard) {
ret = bs->drv->bdrv_co_discard(bs, offset >> BDRV_SECTOR_BITS,
num >> BDRV_SECTOR_BITS);
} else {