aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-02-03 16:21:58 +0100
committerKevin Wolf <kwolf@redhat.com>2023-02-23 19:49:26 +0100
commit79a292e5ec767eea27a0cc456570ee028f4e3972 (patch)
tree22f03a4c1f1cdc65a8cbde01222126ae8f3de82e /block
parentc73ff92c9d00f9aa535044e7348d0330aa94f467 (diff)
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>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c2
-rw-r--r--block/copy-on-read.c6
-rw-r--r--block/filter-compress.c4
-rw-r--r--block/raw-format.c6
4 files changed, 12 insertions, 6 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 20af699f00..278b04ce69 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -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);
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
index 78da353f88..20215cff93 100644
--- a/block/copy-on-read.c
+++ b/block/copy-on-read.c
@@ -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);
}
diff --git a/block/filter-compress.c b/block/filter-compress.c
index 0dd5606410..c7d50a67a7 100644
--- a/block/filter-compress.c
+++ b/block/filter-compress.c
@@ -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);
diff --git a/block/raw-format.c b/block/raw-format.c
index 646606e223..f4203d4806 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -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);
}