mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
block: Mark bdrv_(un)freeze_backing_chain() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_(un)freeze_backing_chain() need to hold a reader lock for the graph because it calls bdrv_filter_or_cow_child(), which accesses bs->file/backing. Use the opportunity to make bdrv_is_backing_chain_frozen() static, it has no external callers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-10-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
ad74751fc0
commit
9275fc72bd
7 changed files with 46 additions and 17 deletions
|
@ -35,8 +35,8 @@ typedef struct BDRVStateCOR {
|
|||
} BDRVStateCOR;
|
||||
|
||||
|
||||
static int cor_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
Error **errp)
|
||||
static int GRAPH_UNLOCKED
|
||||
cor_open(BlockDriverState *bs, QDict *options, int flags, Error **errp)
|
||||
{
|
||||
BlockDriverState *bottom_bs = NULL;
|
||||
BDRVStateCOR *state = bs->opaque;
|
||||
|
@ -44,6 +44,8 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
const char *bottom_node = qdict_get_try_str(options, "bottom");
|
||||
int ret;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
ret = bdrv_open_file_child(NULL, options, "file", bs, errp);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
@ -59,6 +61,8 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
bs->file->bs->supported_zero_flags);
|
||||
|
||||
if (bottom_node) {
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
|
||||
bottom_bs = bdrv_find_node(bottom_node);
|
||||
if (!bottom_bs) {
|
||||
error_setg(errp, "Bottom node '%s' not found", bottom_node);
|
||||
|
@ -227,13 +231,17 @@ cor_co_lock_medium(BlockDriverState *bs, bool locked)
|
|||
}
|
||||
|
||||
|
||||
static void cor_close(BlockDriverState *bs)
|
||||
static void GRAPH_UNLOCKED cor_close(BlockDriverState *bs)
|
||||
{
|
||||
BDRVStateCOR *s = bs->opaque;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
if (s->chain_frozen) {
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
s->chain_frozen = false;
|
||||
bdrv_unfreeze_backing_chain(bs, s->bottom_bs);
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
}
|
||||
|
||||
bdrv_unref(s->bottom_bs);
|
||||
|
@ -263,12 +271,15 @@ static BlockDriver bdrv_copy_on_read = {
|
|||
};
|
||||
|
||||
|
||||
void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs)
|
||||
void no_coroutine_fn bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs)
|
||||
{
|
||||
BDRVStateCOR *s = cor_filter_bs->opaque;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
/* unfreeze, as otherwise bdrv_replace_node() will fail */
|
||||
if (s->chain_frozen) {
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
s->chain_frozen = false;
|
||||
bdrv_unfreeze_backing_chain(cor_filter_bs, s->bottom_bs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue