[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 12/37] block: Fix BB AIOCB AioContext without BDS
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 12/37] block: Fix BB AIOCB AioContext without BDS |
Date: |
Fri, 23 Oct 2015 19:00:59 +0200 |
From: Max Reitz <address@hidden>
Fix the BlockBackend's AIOCB AioContext for aborting AIO in case there
is no BDS. If there is no implementation of AIOCBInfo::get_aio_context()
the AioContext is derived from the BDS the AIOCB belongs to. If that BDS
is NULL (because it has been removed from the BB) this will not work.
This patch makes blk_get_aio_context() fall back to the main loop
context if the BDS pointer is NULL and implements
AIOCBInfo::get_aio_context() (blk_aiocb_get_aio_context()) which invokes
blk_get_aio_context().
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/block-backend.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 74642dc..c7e0f7b 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -18,6 +18,8 @@
/* Number of coroutines to reserve per attached device model */
#define COROUTINE_POOL_RESERVATION 64
+static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb);
+
struct BlockBackend {
char *name;
int refcnt;
@@ -34,10 +36,12 @@ struct BlockBackend {
typedef struct BlockBackendAIOCB {
BlockAIOCB common;
QEMUBH *bh;
+ BlockBackend *blk;
int ret;
} BlockBackendAIOCB;
static const AIOCBInfo block_backend_aiocb_info = {
+ .get_aio_context = blk_aiocb_get_aio_context,
.aiocb_size = sizeof(BlockBackendAIOCB),
};
@@ -558,6 +562,7 @@ static BlockAIOCB *abort_aio_request(BlockBackend *blk,
BlockCompletionFunc *cb,
QEMUBH *bh;
acb = blk_aio_get(&block_backend_aiocb_info, blk, cb, opaque);
+ acb->blk = blk;
acb->ret = ret;
bh = aio_bh_new(blk_get_aio_context(blk), error_callback_bh, acb);
@@ -831,7 +836,17 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason)
AioContext *blk_get_aio_context(BlockBackend *blk)
{
- return bdrv_get_aio_context(blk->bs);
+ if (blk->bs) {
+ return bdrv_get_aio_context(blk->bs);
+ } else {
+ return qemu_get_aio_context();
+ }
+}
+
+static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
+{
+ BlockBackendAIOCB *blk_acb = DO_UPCAST(BlockBackendAIOCB, common, acb);
+ return blk_get_aio_context(blk_acb->blk);
}
void blk_set_aio_context(BlockBackend *blk, AioContext *new_context)
--
1.8.3.1
- [Qemu-block] [PULL 03/37] blockdev: Allow creation of BDS trees without BB, (continued)
- [Qemu-block] [PULL 03/37] blockdev: Allow creation of BDS trees without BB, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 02/37] block: Set BDRV_O_INCOMING in bdrv_fill_options(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 05/37] block: Make bdrv_is_inserted() return a bool, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 06/37] block: Add blk_is_available(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 04/37] iotests: Only create BB if necessary, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 08/37] block/raw_bsd: Drop raw_is_inserted(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 07/37] block: Make bdrv_is_inserted() recursive, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 09/37] block: Invoke change media CB before NULLing drv, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 11/37] hw/usb-storage: Check whether BB is inserted, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 10/37] hw/block/fdc: Implement tray status, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 12/37] block: Fix BB AIOCB AioContext without BDS,
Kevin Wolf <=
- [Qemu-block] [PULL 13/37] block: Move guest_block_size into BlockBackend, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 18/37] block: Add BlockBackendRootState, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 14/37] block: Remove wr_highest_sector from BlockAcctStats, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 17/37] block/throttle-groups: Make incref/decref public, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 15/37] block: Move BlockAcctStats into BlockBackend, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 21/37] block: Prepare remaining BB functions for NULL BDS, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 16/37] block: Move I/O status and error actions into BB, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 22/37] block: Add blk_insert_bs(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 19/37] block: Make some BB functions fall back to BBRS, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 20/37] block: Fail requests to empty BlockBackend, Kevin Wolf, 2015/10/23