block: mark bdrv_open_child_common() and its callers GRAPH_UNLOCKED

The function bdrv_open_child_common() calls
bdrv_graph_wrlock_drained(), which must be called with the graph
unlocked. Mark it and its two callers bdrv_open_file_child() and
bdrv_open_child() as GRAPH_UNLOCKED. This requires temporarily
unlocking in vmdk_parse_extents() and making the locked section
shorter in vmdk_open().

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20250530151125.955508-48-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Fiona Ebner 2025-05-30 17:11:24 +02:00 committed by Kevin Wolf
parent ede0859311
commit 2cf92b15cd
3 changed files with 15 additions and 13 deletions

13
block.c
View File

@ -3766,13 +3766,12 @@ done:
return bs; return bs;
} }
static BdrvChild *bdrv_open_child_common(const char *filename, static BdrvChild * GRAPH_UNLOCKED
QDict *options, const char *bdref_key, bdrv_open_child_common(const char *filename, QDict *options,
BlockDriverState *parent, const char *bdref_key, BlockDriverState *parent,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role, BdrvChildRole child_role, bool allow_none,
bool allow_none, bool parse_filename, bool parse_filename, Error **errp)
Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
BdrvChild *child; BdrvChild *child;

View File

@ -1229,9 +1229,11 @@ vmdk_parse_extents(const char *desc, BlockDriverState *bs, QDict *options,
extent_role |= BDRV_CHILD_METADATA; extent_role |= BDRV_CHILD_METADATA;
} }
bdrv_graph_rdunlock_main_loop();
extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix, extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
bs, &child_of_bds, extent_role, false, bs, &child_of_bds, extent_role, false,
&local_err); &local_err);
bdrv_graph_rdlock_main_loop();
g_free(extent_path); g_free(extent_path);
if (!extent_file) { if (!extent_file) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
@ -1352,13 +1354,13 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
BDRVVmdkState *s = bs->opaque; BDRVVmdkState *s = bs->opaque;
uint32_t magic; uint32_t magic;
GRAPH_RDLOCK_GUARD_MAINLOOP();
ret = bdrv_open_file_child(NULL, options, "file", bs, errp); ret = bdrv_open_file_child(NULL, options, "file", bs, errp);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
GRAPH_RDLOCK_GUARD_MAINLOOP();
buf = vmdk_read_desc(bs->file, 0, errp); buf = vmdk_read_desc(bs->file, 0, errp);
if (!buf) { if (!buf) {
return -EINVAL; return -EINVAL;

View File

@ -81,7 +81,7 @@ bdrv_insert_node(BlockDriverState *bs, QDict *node_options, int flags,
Error **errp); Error **errp);
int bdrv_drop_filter(BlockDriverState *bs, Error **errp); int bdrv_drop_filter(BlockDriverState *bs, Error **errp);
BdrvChild * no_coroutine_fn BdrvChild * no_coroutine_fn GRAPH_UNLOCKED
bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, bdrv_open_child(const char *filename, QDict *options, const char *bdref_key,
BlockDriverState *parent, const BdrvChildClass *child_class, BlockDriverState *parent, const BdrvChildClass *child_class,
BdrvChildRole child_role, bool allow_none, Error **errp); BdrvChildRole child_role, bool allow_none, Error **errp);
@ -91,9 +91,10 @@ bdrv_co_open_child(const char *filename, QDict *options, const char *bdref_key,
BlockDriverState *parent, const BdrvChildClass *child_class, BlockDriverState *parent, const BdrvChildClass *child_class,
BdrvChildRole child_role, bool allow_none, Error **errp); BdrvChildRole child_role, bool allow_none, Error **errp);
int bdrv_open_file_child(const char *filename, int GRAPH_UNLOCKED
QDict *options, const char *bdref_key, bdrv_open_file_child(const char *filename, QDict *options,
BlockDriverState *parent, Error **errp); const char *bdref_key, BlockDriverState *parent,
Error **errp);
BlockDriverState * no_coroutine_fn BlockDriverState * no_coroutine_fn
bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);