[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/71] nbd: Increase bs->in_flight during AioContext
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/71] nbd: Increase bs->in_flight during AioContext switch |
Date: |
Mon, 25 Feb 2019 16:19:58 +0100 |
bdrv_drain() must not leave connection_co scheduled, so bs->in_flight
needs to be increased while the coroutine is waiting to be scheduled
in the new AioContext after nbd_client_attach_aio_context().
Signed-off-by: Kevin Wolf <address@hidden>
---
block/nbd-client.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 60f38f0320..bfbaf7ebe9 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -977,14 +977,30 @@ void nbd_client_detach_aio_context(BlockDriverState *bs)
qio_channel_detach_aio_context(QIO_CHANNEL(client->ioc));
}
+static void nbd_client_attach_aio_context_bh(void *opaque)
+{
+ BlockDriverState *bs = opaque;
+ NBDClientSession *client = nbd_get_client_session(bs);
+
+ /* The node is still drained, so we know the coroutine has yielded in
+ * nbd_read_eof(), the only place where bs->in_flight can reach 0, or it is
+ * entered for the first time. Both places are safe for entering the
+ * coroutine.*/
+ qemu_aio_coroutine_enter(bs->aio_context, client->connection_co);
+ bdrv_dec_in_flight(bs);
+}
+
void nbd_client_attach_aio_context(BlockDriverState *bs,
AioContext *new_context)
{
NBDClientSession *client = nbd_get_client_session(bs);
qio_channel_attach_aio_context(QIO_CHANNEL(client->ioc), new_context);
- /* FIXME Really need a bdrv_inc_in_flight() here */
- aio_co_schedule(new_context, client->connection_co);
+ bdrv_inc_in_flight(bs);
+
+ /* Need to wait here for the BH to run because the BH must run while the
+ * node is still drained. */
+ aio_wait_bh_oneshot(new_context, nbd_client_attach_aio_context_bh, bs);
}
void nbd_client_close(BlockDriverState *bs)
--
2.20.1
- [Qemu-devel] [PULL 07/71] commit: Replace commit_top_bs on failure after deleting the block job, (continued)
- [Qemu-devel] [PULL 07/71] commit: Replace commit_top_bs on failure after deleting the block job, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 06/71] block: don't set the same context, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 09/71] block-backend: Make blk_inc/dec_in_flight public, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 08/71] qemu-img: fix error reporting for -object, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 10/71] virtio-blk: Increase in_flight for request restart BH, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 11/71] nbd: Restrict connection_co reentrance, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 12/71] io: Make qio_channel_yield() interruptible, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 14/71] nbd: Move nbd_read_eof() to nbd/client.c, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 18/71] block: Fix AioContext switch for drained node, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 13/71] io: Remove redundant read/write_coroutine assignments, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 16/71] nbd: Increase bs->in_flight during AioContext switch,
Kevin Wolf <=
- [Qemu-devel] [PULL 20/71] block: Use normal drain for bdrv_set_aio_context(), Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 19/71] test-bdrv-drain: AioContext switch in drained section, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 15/71] nbd: Use low-level QIOChannel API in nbd_read_eof(), Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 17/71] block: Don't poll in bdrv_set_aio_context(), Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 21/71] aio-posix: Assert that aio_poll() is always called in home thread, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 22/71] block: improve should_update_child, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 23/71] block: fix bdrv_check_perm for non-tree subgraph, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 24/71] tests: add test-bdrv-graph-mod, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 25/71] qcow2: Assert that L2 table offsets fit in the L1 table, Kevin Wolf, 2019/02/25
- [Qemu-devel] [PULL 29/71] block: Skip implicit nodes for filename info, Kevin Wolf, 2019/02/25