aboutsummaryrefslogtreecommitdiff
path: root/block/vhdx.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-10-27 17:53:11 +0200
committerKevin Wolf <kwolf@redhat.com>2023-11-07 19:14:19 +0100
commit067179868ec8cd467d9810143339e882cb60e388 (patch)
tree54c38cedf3e8f2433846a664bbd11b01cdaa1895 /block/vhdx.c
parent221caadcc5129d3ec5ad9ecfd7374de0f7050316 (diff)
downloadqemu-067179868ec8cd467d9810143339e882cb60e388.zip
qemu-067179868ec8cd467d9810143339e882cb60e388.tar.gz
qemu-067179868ec8cd467d9810143339e882cb60e388.tar.bz2
block: Mark bdrv_has_zero_init() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_has_zero_init() need to hold a reader lock for the graph because it calls bdrv_filter_bs(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-3-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/vhdx.c')
-rw-r--r--block/vhdx.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/block/vhdx.c b/block/vhdx.c
index a9d0874..e136ba1 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1695,7 +1695,7 @@ exit:
* Fixed images: default state of the BAT is fully populated, with
* file offsets and state PAYLOAD_BLOCK_FULLY_PRESENT.
*/
-static int coroutine_fn
+static int coroutine_fn GRAPH_UNLOCKED
vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
uint64_t image_size, VHDXImageType type,
bool use_zero_blocks, uint64_t file_offset,
@@ -1708,6 +1708,7 @@ vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
uint64_t unused;
int block_state;
VHDXSectorInfo sinfo;
+ bool has_zero_init;
assert(s->bat == NULL);
@@ -1737,9 +1738,13 @@ vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
goto exit;
}
+ bdrv_graph_co_rdlock();
+ has_zero_init = bdrv_has_zero_init(blk_bs(blk));
+ bdrv_graph_co_rdunlock();
+
if (type == VHDX_TYPE_FIXED ||
use_zero_blocks ||
- bdrv_has_zero_init(blk_bs(blk)) == 0) {
+ has_zero_init == 0) {
/* for a fixed file, the default BAT entry is not zero */
s->bat = g_try_malloc0(length);
if (length && s->bat == NULL) {
@@ -1782,7 +1787,7 @@ exit:
* to create the BAT itself, we will also cause the BAT to be
* created.
*/
-static int coroutine_fn
+static int coroutine_fn GRAPH_UNLOCKED
vhdx_create_new_region_table(BlockBackend *blk, uint64_t image_size,
uint32_t block_size, uint32_t sector_size,
uint32_t log_size, bool use_zero_blocks,
@@ -2173,7 +2178,7 @@ static int coroutine_fn vhdx_co_check(BlockDriverState *bs,
return 0;
}
-static int vhdx_has_zero_init(BlockDriverState *bs)
+static int GRAPH_RDLOCK vhdx_has_zero_init(BlockDriverState *bs)
{
BDRVVHDXState *s = bs->opaque;
int state;