Skip to content

Commit

Permalink
block: Mark bdrv_get_specific_info() and callers GRAPH_RDLOCK
Browse files Browse the repository at this point in the history
This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_get_specific_info() need to hold a reader lock for the graph.
This removes an assume_graph_lock() call in vmdk's implementation.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230929145157.45443-20-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
kevmw committed Oct 12, 2023
1 parent 018f9de commit 3574499
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 2 additions & 4 deletions block/vmdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2990,16 +2990,14 @@ vmdk_co_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix)
return ret;
}

static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
Error **errp)
static ImageInfoSpecific * GRAPH_RDLOCK
vmdk_get_specific_info(BlockDriverState *bs, Error **errp)
{
int i;
BDRVVmdkState *s = bs->opaque;
ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);
VmdkExtentInfoList **tail;

assume_graph_lock(); /* FIXME */

*spec_info = (ImageInfoSpecific){
.type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
.u = {
Expand Down
5 changes: 3 additions & 2 deletions include/block/block-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
int co_wrapper_mixed_bdrv_rdlock
bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);

ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
Error **errp);
ImageInfoSpecific * GRAPH_RDLOCK
bdrv_get_specific_info(BlockDriverState *bs, Error **errp);

BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs);
void bdrv_round_to_subclusters(BlockDriverState *bs,
int64_t offset, int64_t bytes,
Expand Down
4 changes: 2 additions & 2 deletions include/block/block_int-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ struct BlockDriver {
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_info)(
BlockDriverState *bs, BlockDriverInfo *bdi);

ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs,
Error **errp);
ImageInfoSpecific * GRAPH_RDLOCK_PTR (*bdrv_get_specific_info)(
BlockDriverState *bs, Error **errp);
BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs);

int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_save_vmstate)(
Expand Down
3 changes: 3 additions & 0 deletions qemu-io-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,9 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
char s1[64], s2[64];
int ret;

GLOBAL_STATE_CODE();
GRAPH_RDLOCK_GUARD_MAINLOOP();

if (bs->drv && bs->drv->format_name) {
printf("format name: %s\n", bs->drv->format_name);
}
Expand Down

0 comments on commit 3574499

Please sign in to comment.