mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
block: Mark bdrv_attach_child() GRAPH_WRLOCK
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_attach_child_common(). These callers will typically already hold the graph lock once the locking work is completed, which means that they can't call functions that take it internally. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20230911094620.45040-13-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5661a00d40
commit
afdaeb9ea0
6 changed files with 43 additions and 10 deletions
|
@ -137,8 +137,10 @@ static void test_update_perm_tree(void)
|
|||
|
||||
blk_insert_bs(root, bs, &error_abort);
|
||||
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(filter, bs, "child", &child_of_bds,
|
||||
BDRV_CHILD_DATA, &error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
aio_context_acquire(qemu_get_aio_context());
|
||||
ret = bdrv_append(filter, bs, NULL);
|
||||
|
@ -205,8 +207,10 @@ static void test_should_update_child(void)
|
|||
bdrv_set_backing_hd(target, bs, &error_abort);
|
||||
|
||||
g_assert(target->backing->bs == bs);
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(filter, target, "target", &child_of_bds,
|
||||
BDRV_CHILD_DATA, &error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
aio_context_acquire(qemu_get_aio_context());
|
||||
bdrv_append(filter, bs, &error_abort);
|
||||
aio_context_release(qemu_get_aio_context());
|
||||
|
@ -236,6 +240,7 @@ static void test_parallel_exclusive_write(void)
|
|||
*/
|
||||
bdrv_ref(base);
|
||||
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(top, fl1, "backing", &child_of_bds,
|
||||
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
|
||||
&error_abort);
|
||||
|
@ -245,6 +250,7 @@ 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);
|
||||
|
||||
|
@ -349,6 +355,7 @@ static void test_parallel_perm_update(void)
|
|||
*/
|
||||
bdrv_ref(base);
|
||||
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(top, ws, "file", &child_of_bds, BDRV_CHILD_DATA,
|
||||
&error_abort);
|
||||
c_fl1 = bdrv_attach_child(ws, fl1, "first", &child_of_bds,
|
||||
|
@ -361,6 +368,7 @@ static void test_parallel_perm_update(void)
|
|||
bdrv_attach_child(fl2, base, "backing", &child_of_bds,
|
||||
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
/* Select fl1 as first child to be active */
|
||||
s->selected = c_fl1;
|
||||
|
@ -410,9 +418,11 @@ static void test_append_greedy_filter(void)
|
|||
BlockDriverState *base = no_perm_node("base");
|
||||
BlockDriverState *fl = exclusive_writer_node("fl1");
|
||||
|
||||
bdrv_graph_wrlock(NULL);
|
||||
bdrv_attach_child(top, base, "backing", &child_of_bds,
|
||||
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
aio_context_acquire(qemu_get_aio_context());
|
||||
bdrv_append(fl, base, &error_abort);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue