mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
block: Mark bdrv_replace_node() GRAPH_WRLOCK
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_replace_node(). Its callers may already want to hold the graph lock and so wouldn't be able to call functions that take it internally. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-17-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5c0ef4954f
commit
ccd6a37947
7 changed files with 64 additions and 35 deletions
|
@ -2000,7 +2000,13 @@ static void do_test_replace_child_mid_drain(int old_drain_count,
|
|||
parent_s->was_undrained = false;
|
||||
|
||||
g_assert(parent_bs->quiesce_counter == old_drain_count);
|
||||
bdrv_drained_begin(old_child_bs);
|
||||
bdrv_drained_begin(new_child_bs);
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_replace_node(old_child_bs, new_child_bs, &error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
bdrv_drained_end(new_child_bs);
|
||||
bdrv_drained_end(old_child_bs);
|
||||
g_assert(parent_bs->quiesce_counter == new_drain_count);
|
||||
|
||||
if (!old_drain_count && !new_drain_count) {
|
||||
|
|
|
@ -234,11 +234,16 @@ static void test_parallel_exclusive_write(void)
|
|||
BlockDriverState *fl1 = pass_through_node("fl1");
|
||||
BlockDriverState *fl2 = pass_through_node("fl2");
|
||||
|
||||
bdrv_drained_begin(fl1);
|
||||
bdrv_drained_begin(fl2);
|
||||
|
||||
/*
|
||||
* bdrv_attach_child() eats child bs reference, so we need two @base
|
||||
* references for two filters:
|
||||
* references for two filters. We also need an additional @fl1 reference so
|
||||
* that it still exists when we want to undrain it.
|
||||
*/
|
||||
bdrv_ref(base);
|
||||
bdrv_ref(fl1);
|
||||
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(top, fl1, "backing", &child_of_bds,
|
||||
|
@ -250,10 +255,14 @@ static void test_parallel_exclusive_write(void)
|
|||
bdrv_attach_child(fl2, base, "backing", &child_of_bds,
|
||||
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
bdrv_replace_node(fl1, fl2, &error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
bdrv_drained_end(fl2);
|
||||
bdrv_drained_end(fl1);
|
||||
|
||||
bdrv_unref(fl1);
|
||||
bdrv_unref(fl2);
|
||||
bdrv_unref(top);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue