block: Mark bdrv_co_eject/lock_medium() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_eject() and bdrv_co_lock_medium() 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> Message-Id: <20230203152202.49054-20-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
c73ff92c9d
commit
79a292e5ec
2
block.c
2
block.c
@ -6849,6 +6849,7 @@ void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (drv && drv->bdrv_co_eject) {
|
||||
drv->bdrv_co_eject(bs, eject_flag);
|
||||
@ -6863,6 +6864,7 @@ void coroutine_fn bdrv_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
trace_bdrv_lock_medium(bs, locked);
|
||||
|
||||
if (drv && drv->bdrv_co_lock_medium) {
|
||||
|
@ -2013,6 +2013,7 @@ void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked)
|
||||
{
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_lock_medium(bs, locked);
|
||||
@ -2024,6 +2025,7 @@ void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag)
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
char *id;
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_eject(bs, eject_flag);
|
||||
|
@ -213,13 +213,15 @@ cor_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn cor_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
bdrv_co_eject(bs->file->bs, eject_flag);
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn cor_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
bdrv_co_lock_medium(bs->file->bs, locked);
|
||||
}
|
||||
|
@ -114,14 +114,14 @@ static void compress_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
bdrv_co_eject(bs->file->bs, eject_flag);
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
bdrv_co_lock_medium(bs->file->bs, locked);
|
||||
|
@ -405,12 +405,14 @@ raw_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
|
||||
return bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp);
|
||||
}
|
||||
|
||||
static void coroutine_fn raw_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
bdrv_co_eject(bs->file->bs, eject_flag);
|
||||
}
|
||||
|
||||
static void coroutine_fn raw_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
bdrv_co_lock_medium(bs->file->bs, locked);
|
||||
}
|
||||
|
@ -148,8 +148,11 @@ int bdrv_get_flags(BlockDriverState *bs);
|
||||
bool coroutine_fn GRAPH_RDLOCK bdrv_co_is_inserted(BlockDriverState *bs);
|
||||
bool co_wrapper_bdrv_rdlock bdrv_is_inserted(BlockDriverState *bs);
|
||||
|
||||
void coroutine_fn bdrv_co_lock_medium(BlockDriverState *bs, bool locked);
|
||||
void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag);
|
||||
void coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_lock_medium(BlockDriverState *bs, bool locked);
|
||||
|
||||
void coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_eject(BlockDriverState *bs, bool eject_flag);
|
||||
|
||||
const char *bdrv_get_format_name(BlockDriverState *bs);
|
||||
|
||||
|
@ -714,8 +714,10 @@ struct BlockDriver {
|
||||
/* removable device specific */
|
||||
bool coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_is_inserted)(
|
||||
BlockDriverState *bs);
|
||||
void coroutine_fn (*bdrv_co_eject)(BlockDriverState *bs, bool eject_flag);
|
||||
void coroutine_fn (*bdrv_co_lock_medium)(BlockDriverState *bs, bool locked);
|
||||
void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_eject)(
|
||||
BlockDriverState *bs, bool eject_flag);
|
||||
void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_lock_medium)(
|
||||
BlockDriverState *bs, bool locked);
|
||||
|
||||
/* to control generic scsi devices */
|
||||
BlockAIOCB *coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_aio_ioctl)(
|
||||
|
Loading…
x
Reference in New Issue
Block a user