mirror of https://github.com/xemu-project/xemu.git
block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_refresh_total_sectors() need to hold a reader lock for the graph. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230203152202.49054-24-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
167f748d8c
commit
8ab8140a04
3
block.c
3
block.c
|
@ -1042,6 +1042,7 @@ int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs,
|
||||||
{
|
{
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
|
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
|
@ -5843,6 +5844,7 @@ int64_t coroutine_fn bdrv_co_nb_sectors(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
|
|
||||||
if (!drv)
|
if (!drv)
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
|
@ -5864,6 +5866,7 @@ int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
int64_t ret;
|
int64_t ret;
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
|
|
||||||
ret = bdrv_co_nb_sectors(bs);
|
ret = bdrv_co_nb_sectors(bs);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -967,7 +967,8 @@ static bool blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn blkdebug_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
blkdebug_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,8 @@ static void blk_log_writes_close(BlockDriverState *bs)
|
||||||
s->log_file = NULL;
|
s->log_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn blk_log_writes_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
blk_log_writes_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn blkreplay_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
blkreplay_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,8 @@ static void blkverify_close(BlockDriverState *bs)
|
||||||
s->test_file = NULL;
|
s->test_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn blkverify_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
blkverify_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BDRVBlkverifyState *s = bs->opaque;
|
BDRVBlkverifyState *s = bs->opaque;
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t coroutine_fn cor_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK cor_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,8 @@ static void block_crypto_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t coroutine_fn block_crypto_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
block_crypto_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BlockCrypto *crypto = bs->opaque;
|
BlockCrypto *crypto = bs->opaque;
|
||||||
int64_t len = bdrv_co_getlength(bs->file->bs);
|
int64_t len = bdrv_co_getlength(bs->file->bs);
|
||||||
|
|
|
@ -55,7 +55,8 @@ static int compress_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t coroutine_fn compress_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
compress_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -917,7 +917,10 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||||
goto immediate_exit;
|
goto immediate_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdrv_graph_co_rdlock();
|
||||||
s->bdev_length = bdrv_co_getlength(bs);
|
s->bdev_length = bdrv_co_getlength(bs);
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
|
|
||||||
if (s->bdev_length < 0) {
|
if (s->bdev_length < 0) {
|
||||||
ret = s->bdev_length;
|
ret = s->bdev_length;
|
||||||
goto immediate_exit;
|
goto immediate_exit;
|
||||||
|
|
|
@ -443,7 +443,8 @@ static int coroutine_fn GRAPH_RDLOCK preallocate_co_flush(BlockDriverState *bs)
|
||||||
return bdrv_co_flush(bs->file->bs);
|
return bdrv_co_flush(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn preallocate_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
preallocate_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
int64_t ret;
|
int64_t ret;
|
||||||
BDRVPreallocateState *s = bs->opaque;
|
BDRVPreallocateState *s = bs->opaque;
|
||||||
|
|
|
@ -764,7 +764,8 @@ quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
flags | BDRV_REQ_ZERO_WRITE);
|
flags | BDRV_REQ_ZERO_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn quorum_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
quorum_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BDRVQuorumState *s = bs->opaque;
|
BDRVQuorumState *s = bs->opaque;
|
||||||
int64_t result;
|
int64_t result;
|
||||||
|
|
|
@ -317,7 +317,8 @@ raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||||
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
raw_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
int64_t len;
|
int64_t len;
|
||||||
BDRVRawState *s = bs->opaque;
|
BDRVRawState *s = bs->opaque;
|
||||||
|
|
|
@ -179,7 +179,8 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t coroutine_fn replication_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
replication_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,9 +141,11 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = bdrv_getlength(s->target_bs);
|
WITH_GRAPH_RDLOCK_GUARD() {
|
||||||
if (len < 0) {
|
len = bdrv_co_getlength(s->target_bs);
|
||||||
return len;
|
if (len < 0) {
|
||||||
|
return len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
job_progress_set_remaining(&s->common.job, len);
|
job_progress_set_remaining(&s->common.job, len);
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,8 @@ static void throttle_close(BlockDriverState *bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t coroutine_fn throttle_co_getlength(BlockDriverState *bs)
|
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||||
|
throttle_co_getlength(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
return bdrv_co_getlength(bs->file->bs);
|
return bdrv_co_getlength(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,11 +78,11 @@ int coroutine_fn GRAPH_RDLOCK
|
||||||
bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
|
bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
|
||||||
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
|
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
|
||||||
|
|
||||||
int64_t coroutine_fn bdrv_co_nb_sectors(BlockDriverState *bs);
|
int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_nb_sectors(BlockDriverState *bs);
|
||||||
int64_t co_wrapper_mixed bdrv_nb_sectors(BlockDriverState *bs);
|
int64_t co_wrapper_mixed_bdrv_rdlock bdrv_nb_sectors(BlockDriverState *bs);
|
||||||
|
|
||||||
int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs);
|
int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_getlength(BlockDriverState *bs);
|
||||||
int64_t co_wrapper_mixed bdrv_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 coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs);
|
||||||
int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs);
|
int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs);
|
||||||
|
|
|
@ -684,7 +684,9 @@ struct BlockDriver {
|
||||||
BlockDriverState *bs, int64_t offset, bool exact,
|
BlockDriverState *bs, int64_t offset, bool exact,
|
||||||
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
|
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
|
||||||
|
|
||||||
int64_t coroutine_fn (*bdrv_co_getlength)(BlockDriverState *bs);
|
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 (*bdrv_co_get_allocated_file_size)(
|
||||||
BlockDriverState *bs);
|
BlockDriverState *bs);
|
||||||
|
|
||||||
|
|
|
@ -124,9 +124,10 @@ bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
|
||||||
int64_t bytes, BdrvRequestFlags read_flags,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
BdrvRequestFlags write_flags);
|
BdrvRequestFlags write_flags);
|
||||||
|
|
||||||
int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs,
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
int64_t hint);
|
bdrv_co_refresh_total_sectors(BlockDriverState *bs, int64_t hint);
|
||||||
int co_wrapper_mixed
|
|
||||||
|
int co_wrapper_mixed_bdrv_rdlock
|
||||||
bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint);
|
bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint);
|
||||||
|
|
||||||
BdrvChild *bdrv_cow_child(BlockDriverState *bs);
|
BdrvChild *bdrv_cow_child(BlockDriverState *bs);
|
||||||
|
|
Loading…
Reference in New Issue