[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 09/17] block: Add .bdrv_co_pdiscard() driver callbac
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH 09/17] block: Add .bdrv_co_pdiscard() driver callback |
Date: |
Wed, 22 Jun 2016 09:51:06 -0600 |
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 <address@hidden>
---
include/block/block_int.h | 2 ++
block/io.c | 7 +++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 880a6d8..61e5b5a 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -167,6 +167,8 @@ struct BlockDriver {
int64_t offset, int count, BdrvRequestFlags flags);
int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs,
int64_t sector_num, int nb_sectors);
+ int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs,
+ int64_t offset, int count);
int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *pnum,
BlockDriverState **file);
diff --git a/block/io.c b/block/io.c
index d8dc014..9d1f36d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2394,7 +2394,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;
}
@@ -2426,7 +2427,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 {
--
2.5.5
- [Qemu-block] [PATCH 00/17] byte-based block discard, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 07/17] rbd: Switch rbd_start_aio() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 09/17] block: Add .bdrv_co_pdiscard() driver callback,
Eric Blake <=
- [Qemu-block] [PATCH 08/17] block: Convert .bdrv_aio_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 03/17] block: Switch BlockRequest to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 02/17] block: Convert bdrv_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 04/17] block: Convert bdrv_aio_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 10/17] blkreplay: Switch .bdrv_co_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 01/17] block: Convert bdrv_co_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 11/17] gluster: Switch .bdrv_co_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 12/17] iscsi: Switch .bdrv_co_discard() to byte-based, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 05/17] block: Convert BB interface to byte-based discards, Eric Blake, 2016/06/22
- [Qemu-block] [PATCH 13/17] nbd: Switch .bdrv_co_discard() to byte-based, Eric Blake, 2016/06/22