mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
block: Mark bdrv_filter_or_cow_bs() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_filter_or_cow_bs() need to hold a reader lock for the graph because it calls bdrv_filter_or_cow_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-7-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
33
block.c
33
block.c
@ -5435,17 +5435,6 @@ static int bdrv_replace_node_common(BlockDriverState *from,
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
if (detach_subchain) {
|
||||
assert(bdrv_chain_contains(from, to));
|
||||
assert(from != to);
|
||||
for (to_cow_parent = from;
|
||||
bdrv_filter_or_cow_bs(to_cow_parent) != to;
|
||||
to_cow_parent = bdrv_filter_or_cow_bs(to_cow_parent))
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure that @from doesn't go away until we have successfully attached
|
||||
* all of its parents to @to. */
|
||||
bdrv_ref(from);
|
||||
@ -5457,6 +5446,17 @@ static int bdrv_replace_node_common(BlockDriverState *from,
|
||||
|
||||
bdrv_graph_wrlock(to);
|
||||
|
||||
if (detach_subchain) {
|
||||
assert(bdrv_chain_contains(from, to));
|
||||
assert(from != to);
|
||||
for (to_cow_parent = from;
|
||||
bdrv_filter_or_cow_bs(to_cow_parent) != to;
|
||||
to_cow_parent = bdrv_filter_or_cow_bs(to_cow_parent))
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the replacement without permission update.
|
||||
* Replacement may influence the permissions, we should calculate new
|
||||
@ -5504,10 +5504,14 @@ int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
|
||||
|
||||
int bdrv_drop_filter(BlockDriverState *bs, Error **errp)
|
||||
{
|
||||
GLOBAL_STATE_CODE();
|
||||
BlockDriverState *child_bs;
|
||||
|
||||
return bdrv_replace_node_common(bs, bdrv_filter_or_cow_bs(bs), true, true,
|
||||
errp);
|
||||
GLOBAL_STATE_CODE();
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
child_bs = bdrv_filter_or_cow_bs(bs);
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
|
||||
return bdrv_replace_node_common(bs, child_bs, true, true, errp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6509,6 +6513,7 @@ bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base)
|
||||
{
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
|
||||
while (top && top != base) {
|
||||
top = bdrv_filter_or_cow_bs(top);
|
||||
|
Reference in New Issue
Block a user