[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard |
Date: |
Thu, 27 Oct 2016 20:08:46 +0200 |
All read/write functions already have a single coroutine-based function
on the BlockBackend level through which all requests go (no matter what
API style the external caller used) and which passes the requests down
to the block node level.
This patch extends this mode of operation to discards.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/block-backend.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 96bb634..39336de 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1114,16 +1114,21 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk,
return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
}
+static void blk_aio_pdiscard_entry(void *opaque)
+{
+ BlkAioEmAIOCB *acb = opaque;
+ BlkRwCo *rwco = &acb->rwco;
+
+ rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, acb->bytes);
+ blk_aio_complete(acb);
+}
+
BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
int64_t offset, int count,
BlockCompletionFunc *cb, void *opaque)
{
- int ret = blk_check_byte_request(blk, offset, count);
- if (ret < 0) {
- return blk_abort_aio_request(blk, cb, opaque, ret);
- }
-
- return bdrv_aio_pdiscard(blk_bs(blk), offset, count, cb, opaque);
+ return blk_aio_prwv(blk, offset, count, NULL, blk_aio_pdiscard_entry, 0,
+ cb, opaque);
}
void blk_aio_cancel(BlockAIOCB *acb)
@@ -1562,14 +1567,15 @@ int blk_truncate(BlockBackend *blk, int64_t offset)
return bdrv_truncate(blk_bs(blk), offset);
}
-int blk_pdiscard(BlockBackend *blk, int64_t offset, int count)
+static void blk_pdiscard_entry(void *opaque)
{
- int ret = blk_check_byte_request(blk, offset, count);
- if (ret < 0) {
- return ret;
- }
+ BlkRwCo *rwco = opaque;
+ rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, rwco->qiov->size);
+}
- return bdrv_pdiscard(blk_bs(blk), offset, count);
+int blk_pdiscard(BlockBackend *blk, int64_t offset, int count)
+{
+ return blk_prw(blk, offset, NULL, count, blk_pdiscard_entry, 0);
}
int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
--
1.8.3.1
- [Qemu-devel] [PULL 12/23] quorum: do not allocate multiple iovecs for FIFO strategy, (continued)
- [Qemu-devel] [PULL 12/23] quorum: do not allocate multiple iovecs for FIFO strategy, Kevin Wolf, 2016/10/24
- [Qemu-devel] [PULL 14/23] HBitmap: Introduce "meta" bitmap to track bit changes, Kevin Wolf, 2016/10/24
- [Qemu-devel] [PULL 22/23] block: More operations for meta dirty bitmap, Kevin Wolf, 2016/10/24
- [Qemu-devel] [PULL 21/23] tests: Add test code for hbitmap serialization, Kevin Wolf, 2016/10/24
- [Qemu-devel] [PULL 20/23] block: BdrvDirtyBitmap serialization interface, Kevin Wolf, 2016/10/24
- [Qemu-devel] [PULL 23/23] block/replication: Clarify 'top-id' parameter usage, Kevin Wolf, 2016/10/24
- Re: [Qemu-devel] [PULL 00/23] Block layer patches, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 00/23] Block layer patches, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard(), Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard,
Kevin Wolf <=
- [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl(), Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl(), Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl(), Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host, Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename(), Kevin Wolf, 2016/10/27
- [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX, Kevin Wolf, 2016/10/27