Skip to content

Commit

Permalink
block: Mark bdrv_co_get_allocated_file_size() 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_co_get_allocated_file_size() need to hold a reader lock for the
graph.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20230504115750.54437-14-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
esposem authored and kevmw committed May 10, 2023
1 parent 9c93652 commit de33563
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion block.c
Original file line number Diff line number Diff line change
Expand Up @@ -5750,7 +5750,8 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
* sums the size of all data-bearing children. (This excludes backing
* children.)
*/
static int64_t coroutine_fn bdrv_sum_allocated_file_size(BlockDriverState *bs)
static int64_t coroutine_fn GRAPH_RDLOCK
bdrv_sum_allocated_file_size(BlockDriverState *bs)
{
BdrvChild *child;
int64_t child_size, sum = 0;
Expand Down Expand Up @@ -5778,6 +5779,7 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
IO_CODE();
assert_bdrv_graph_readable();

if (!drv) {
return -ENOMEDIUM;
Expand Down
2 changes: 1 addition & 1 deletion block/vmdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2845,7 +2845,7 @@ static void vmdk_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}

static int64_t coroutine_fn
static int64_t coroutine_fn GRAPH_RDLOCK
vmdk_co_get_allocated_file_size(BlockDriverState *bs)
{
int i;
Expand Down
7 changes: 5 additions & 2 deletions include/block/block-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ int64_t coroutine_mixed_fn bdrv_nb_sectors(BlockDriverState *bs);
int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_getlength(BlockDriverState *bs);
int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(BlockDriverState *bs);

int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs);
int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs);
int64_t coroutine_fn GRAPH_RDLOCK
bdrv_co_get_allocated_file_size(BlockDriverState *bs);

int64_t co_wrapper_bdrv_rdlock
bdrv_get_allocated_file_size(BlockDriverState *bs);

BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
BlockDriverState *in_bs, Error **errp);
Expand Down
2 changes: 1 addition & 1 deletion include/block/block_int-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ struct BlockDriver {
int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_getlength)(
BlockDriverState *bs);

int64_t coroutine_fn (*bdrv_co_get_allocated_file_size)(
int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_allocated_file_size)(
BlockDriverState *bs);

BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs,
Expand Down

0 comments on commit de33563

Please sign in to comment.