[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 10/16] block: drain from main loop thread in bdrv_co_yield_to_
From: |
Stefan Hajnoczi |
Subject: |
[PATCH v2 10/16] block: drain from main loop thread in bdrv_co_yield_to_drain() |
Date: |
Wed, 19 Apr 2023 13:28:11 -0400 |
For simplicity, always run BlockDevOps .drained_begin/end/poll()
callbacks in the main loop thread. This makes it easier to implement the
callbacks and avoids extra locks.
Move the function pointer declarations from the I/O Code section to the
Global State section in block-backend-common.h.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
include/sysemu/block-backend-common.h | 25 +++++++++++++------------
block/io.c | 3 ++-
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/include/sysemu/block-backend-common.h
b/include/sysemu/block-backend-common.h
index 2391679c56..780cea7305 100644
--- a/include/sysemu/block-backend-common.h
+++ b/include/sysemu/block-backend-common.h
@@ -59,6 +59,19 @@ typedef struct BlockDevOps {
*/
bool (*is_medium_locked)(void *opaque);
+ /*
+ * Runs when the backend receives a drain request.
+ */
+ void (*drained_begin)(void *opaque);
+ /*
+ * Runs when the backend's last drain request ends.
+ */
+ void (*drained_end)(void *opaque);
+ /*
+ * Is the device still busy?
+ */
+ bool (*drained_poll)(void *opaque);
+
/*
* I/O API functions. These functions are thread-safe.
*
@@ -76,18 +89,6 @@ typedef struct BlockDevOps {
* Runs when the size changed (e.g. monitor command block_resize)
*/
void (*resize_cb)(void *opaque);
- /*
- * Runs when the backend receives a drain request.
- */
- void (*drained_begin)(void *opaque);
- /*
- * Runs when the backend's last drain request ends.
- */
- void (*drained_end)(void *opaque);
- /*
- * Is the device still busy?
- */
- bool (*drained_poll)(void *opaque);
} BlockDevOps;
/*
diff --git a/block/io.c b/block/io.c
index db438c7657..6285d67546 100644
--- a/block/io.c
+++ b/block/io.c
@@ -331,7 +331,8 @@ static void coroutine_fn
bdrv_co_yield_to_drain(BlockDriverState *bs,
if (ctx != co_ctx) {
aio_context_release(ctx);
}
- replay_bh_schedule_oneshot_event(ctx, bdrv_co_drain_bh_cb, &data);
+ replay_bh_schedule_oneshot_event(qemu_get_aio_context(),
+ bdrv_co_drain_bh_cb, &data);
qemu_coroutine_yield();
/* If we are resumed from some other event (such as an aio completion or a
--
2.39.2
- [PATCH v2 02/16] virtio-scsi: avoid race between unplug and transport event, (continued)
- [PATCH v2 02/16] virtio-scsi: avoid race between unplug and transport event, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 03/16] virtio-scsi: stop using aio_disable_external() during unplug, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 04/16] block/export: only acquire AioContext once for vhost_user_server_stop(), Stefan Hajnoczi, 2023/04/19
- [PATCH v2 05/16] util/vhost-user-server: rename refcount to in_flight counter, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 06/16] block/export: wait for vhost-user-blk requests when draining, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 07/16] block/export: stop using is_external in vhost-user-blk server, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 09/16] block: add blk_in_drain() API, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 08/16] hw/xen: do not use aio_set_fd_handler(is_external=true) in xen_xenstore, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 10/16] block: drain from main loop thread in bdrv_co_yield_to_drain(),
Stefan Hajnoczi <=
- [PATCH v2 11/16] xen-block: implement BlockDevOps->drained_begin(), Stefan Hajnoczi, 2023/04/19
- [PATCH v2 12/16] hw/xen: do not set is_external=true on evtchn fds, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 13/16] block/export: rewrite vduse-blk drain code, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 14/16] block/export: don't require AioContext lock around blk_exp_ref/unref(), Stefan Hajnoczi, 2023/04/19
- [PATCH v2 15/16] block/fuse: do not set is_external=true on FUSE fd, Stefan Hajnoczi, 2023/04/19
- [PATCH v2 16/16] virtio: make it possible to detach host notifier from any thread, Stefan Hajnoczi, 2023/04/19