[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/26] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutin
From: |
Kevin Wolf |
Subject: |
[PULL 05/26] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context |
Date: |
Thu, 12 Oct 2023 18:22:03 +0200 |
AIO callbacks are effectively coroutine_mixed_fn. If AIO requests don't
return immediately, their callback is called from the request coroutine.
This means that in AIO callbacks, we can't call no_coroutine_fns such as
bdrv_graph_wrlock(). Unfortunately test-bdrv-drain does so.
Change the test to use a BH to drop out of coroutine context, and add
coroutine_mixed_fn and no_coroutine_fn markers to clarify the context
each function runs in.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230929145157.45443-2-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/unit/test-bdrv-drain.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
index 0b603e7c57..bdd3757615 100644
--- a/tests/unit/test-bdrv-drain.c
+++ b/tests/unit/test-bdrv-drain.c
@@ -1168,7 +1168,7 @@ struct detach_by_parent_data {
};
static struct detach_by_parent_data detach_by_parent_data;
-static void detach_indirect_bh(void *opaque)
+static void no_coroutine_fn detach_indirect_bh(void *opaque)
{
struct detach_by_parent_data *data = opaque;
@@ -1184,14 +1184,15 @@ static void detach_indirect_bh(void *opaque)
bdrv_graph_wrunlock();
}
-static void detach_by_parent_aio_cb(void *opaque, int ret)
+static void coroutine_mixed_fn detach_by_parent_aio_cb(void *opaque, int ret)
{
struct detach_by_parent_data *data = &detach_by_parent_data;
g_assert_cmpint(ret, ==, 0);
if (data->by_parent_cb) {
bdrv_inc_in_flight(data->child_b->bs);
- detach_indirect_bh(data);
+ aio_bh_schedule_oneshot(qemu_get_current_aio_context(),
+ detach_indirect_bh, &detach_by_parent_data);
}
}
--
2.41.0
- [PULL 00/26] Block layer patches, Kevin Wolf, 2023/10/12
- [PULL 06/26] block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functions, Kevin Wolf, 2023/10/12
- [PULL 14/26] block: Mark bdrv_refresh_filename() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 07/26] block: Take graph rdlock in bdrv_inactivate_all(), Kevin Wolf, 2023/10/12
- [PULL 17/26] block: Mark bdrv_amend_options() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 03/26] block: switch to co_wrapper for bdrv_is_allocated_*, Kevin Wolf, 2023/10/12
- [PULL 11/26] block: Mark bdrv_snapshot_fallback() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 02/26] block: complete public block status API, Kevin Wolf, 2023/10/12
- [PULL 09/26] block: Mark drain related functions GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 05/26] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context,
Kevin Wolf <=
- [PULL 13/26] block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 19/26] qcow2: Mark qcow2_inactivate() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 12/26] block: Take graph rdlock in parts of reopen, Kevin Wolf, 2023/10/12
- [PULL 10/26] block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 01/26] block: rename the bdrv_co_block_status static function, Kevin Wolf, 2023/10/12
- [PULL 18/26] qcow2: Mark qcow2_signal_corruption() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 04/26] block: convert more bdrv_is_allocated* and bdrv_block_status* calls to coroutine versions, Kevin Wolf, 2023/10/12
- [PULL 22/26] block: Mark bdrv_apply_auto_read_only() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12
- [PULL 24/26] block: Protect bs->parents with graph_lock, Kevin Wolf, 2023/10/12
- [PULL 16/26] block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/10/12