Skip to content

Commit 79a5586

Browse files
committed
block: Add missing GRAPH_RDLOCK annotations
This adds GRAPH_RDLOCK to some driver callbacks that are already called with the graph lock held, and which will need the annotation because they access bs->file, but don't have it yet. This also covers a few callbacks that were not marked GRAPH_RDLOCK before, but where updating BlockDriver is trivially possible. Signed-off-by: Kevin Wolf <[email protected]> Message-ID: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent e2dd273 commit 79a5586

File tree

16 files changed

+55
-60
lines changed

16 files changed

+55
-60
lines changed

block/blkdebug.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,10 @@ blkdebug_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
746746
return bdrv_co_pdiscard(bs->file, offset, bytes);
747747
}
748748

749-
static int coroutine_fn blkdebug_co_block_status(BlockDriverState *bs,
750-
bool want_zero,
751-
int64_t offset,
752-
int64_t bytes,
753-
int64_t *pnum,
754-
int64_t *map,
755-
BlockDriverState **file)
749+
static int coroutine_fn GRAPH_RDLOCK
750+
blkdebug_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset,
751+
int64_t bytes, int64_t *pnum, int64_t *map,
752+
BlockDriverState **file)
756753
{
757754
int err;
758755

@@ -973,7 +970,7 @@ blkdebug_co_getlength(BlockDriverState *bs)
973970
return bdrv_co_getlength(bs->file->bs);
974971
}
975972

976-
static void blkdebug_refresh_filename(BlockDriverState *bs)
973+
static void GRAPH_RDLOCK blkdebug_refresh_filename(BlockDriverState *bs)
977974
{
978975
BDRVBlkdebugState *s = bs->opaque;
979976
const QDictEntry *e;

block/blkverify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ blkverify_recurse_can_replace(BlockDriverState *bs,
288288
bdrv_recurse_can_replace(s->test_file->bs, to_replace);
289289
}
290290

291-
static void blkverify_refresh_filename(BlockDriverState *bs)
291+
static void GRAPH_RDLOCK blkverify_refresh_filename(BlockDriverState *bs)
292292
{
293293
BDRVBlkverifyState *s = bs->opaque;
294294

block/copy-before-write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ cbw_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes)
335335
return bdrv_co_pdiscard(s->target, offset, bytes);
336336
}
337337

338-
static void cbw_refresh_filename(BlockDriverState *bs)
338+
static void GRAPH_RDLOCK cbw_refresh_filename(BlockDriverState *bs)
339339
{
340340
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename),
341341
bs->file->bs->filename);

block/filter-compress.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ compress_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
9797
}
9898

9999

100-
static void compress_refresh_limits(BlockDriverState *bs, Error **errp)
100+
static void GRAPH_RDLOCK
101+
compress_refresh_limits(BlockDriverState *bs, Error **errp)
101102
{
102103
BlockDriverInfo bdi;
103104
int ret;

block/io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,8 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
36853685
void bdrv_cancel_in_flight(BlockDriverState *bs)
36863686
{
36873687
GLOBAL_STATE_CODE();
3688+
GRAPH_RDLOCK_GUARD_MAINLOOP();
3689+
36883690
if (!bs || !bs->drv) {
36893691
return;
36903692
}

block/parallels.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,10 @@ parallels_co_flush_to_os(BlockDriverState *bs)
415415
return 0;
416416
}
417417

418-
419-
static int coroutine_fn parallels_co_block_status(BlockDriverState *bs,
420-
bool want_zero,
421-
int64_t offset,
422-
int64_t bytes,
423-
int64_t *pnum,
424-
int64_t *map,
425-
BlockDriverState **file)
418+
static int coroutine_fn GRAPH_RDLOCK
419+
parallels_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset,
420+
int64_t bytes, int64_t *pnum, int64_t *map,
421+
BlockDriverState **file)
426422
{
427423
BDRVParallelsState *s = bs->opaque;
428424
int count;

block/preallocate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ static void preallocate_drop_resize_bh(void *opaque)
541541
preallocate_drop_resize(opaque, NULL);
542542
}
543543

544-
static void preallocate_set_perm(BlockDriverState *bs,
545-
uint64_t perm, uint64_t shared)
544+
static void GRAPH_RDLOCK
545+
preallocate_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared)
546546
{
547547
BDRVPreallocateState *s = bs->opaque;
548548

block/qcow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ qcow_co_create_opts(BlockDriver *drv, const char *filename,
10241024
return ret;
10251025
}
10261026

1027-
static int qcow_make_empty(BlockDriverState *bs)
1027+
static int GRAPH_RDLOCK qcow_make_empty(BlockDriverState *bs)
10281028
{
10291029
BDRVQcowState *s = bs->opaque;
10301030
uint32_t l1_length = s->l1_size * sizeof(uint64_t);

block/qcow2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5226,8 +5226,8 @@ qcow2_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
52265226
return 0;
52275227
}
52285228

5229-
static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
5230-
Error **errp)
5229+
static ImageInfoSpecific * GRAPH_RDLOCK
5230+
qcow2_get_specific_info(BlockDriverState *bs, Error **errp)
52315231
{
52325232
BDRVQcow2State *s = bs->opaque;
52335233
ImageInfoSpecific *spec_info;

block/qcow2.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,12 @@ int GRAPH_RDLOCK
972972
qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id,
973973
const char *name, Error **errp);
974974

975-
int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab);
976-
int qcow2_snapshot_load_tmp(BlockDriverState *bs,
977-
const char *snapshot_id,
978-
const char *name,
979-
Error **errp);
975+
int GRAPH_RDLOCK
976+
qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab);
977+
978+
int GRAPH_RDLOCK
979+
qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_id,
980+
const char *name, Error **errp);
980981

981982
void qcow2_free_snapshots(BlockDriverState *bs);
982983
int coroutine_fn GRAPH_RDLOCK

0 commit comments

Comments
 (0)