[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/23] vmdk: mark more functions as coroutine_fns and GRAPH_RDLOCK
From: |
Kevin Wolf |
Subject: |
[PULL 19/23] vmdk: mark more functions as coroutine_fns and GRAPH_RDLOCK |
Date: |
Wed, 28 Jun 2023 16:15:22 +0200 |
From: Paolo Bonzini <pbonzini@redhat.com>
Mark functions as coroutine_fn when they are only called by other coroutine_fns
and they can suspend. Change calls to co_wrappers to use the non-wrapped
functions, which in turn requires adding GRAPH_RDLOCK annotations.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20230601115145.196465-9-pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vmdk.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index e3e86608ec..0410b895dc 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -339,7 +339,8 @@ out:
return ret;
}
-static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
+static int coroutine_fn GRAPH_RDLOCK
+vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
{
char *desc, *tmp_desc;
char *p_name, *tmp_str;
@@ -348,7 +349,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t
cid)
desc = g_malloc0(DESC_SIZE);
tmp_desc = g_malloc0(DESC_SIZE);
- ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
+ ret = bdrv_co_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
if (ret < 0) {
goto out;
}
@@ -368,7 +369,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t
cid)
pstrcat(desc, DESC_SIZE, tmp_desc);
}
- ret = bdrv_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
+ ret = bdrv_co_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
out:
g_free(desc);
@@ -2165,7 +2166,7 @@ vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t
offset, int64_t bytes,
return ret;
}
-static int GRAPH_UNLOCKED
+static int coroutine_fn GRAPH_UNLOCKED
vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress,
bool zeroed_grain, Error **errp)
{
@@ -2176,7 +2177,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize,
bool flat, bool compress,
int gd_buf_size;
if (flat) {
- ret = blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0, errp);
+ ret = blk_co_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0,
errp);
goto exit;
}
magic = cpu_to_be32(VMDK4_MAGIC);
@@ -2228,19 +2229,19 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize,
bool flat, bool compress,
header.check_bytes[3] = 0xa;
/* write all the data */
- ret = blk_pwrite(blk, 0, sizeof(magic), &magic, 0);
+ ret = blk_co_pwrite(blk, 0, sizeof(magic), &magic, 0);
if (ret < 0) {
error_setg(errp, QERR_IO_ERROR);
goto exit;
}
- ret = blk_pwrite(blk, sizeof(magic), sizeof(header), &header, 0);
+ ret = blk_co_pwrite(blk, sizeof(magic), sizeof(header), &header, 0);
if (ret < 0) {
error_setg(errp, QERR_IO_ERROR);
goto exit;
}
- ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false,
- PREALLOC_MODE_OFF, 0, errp);
+ ret = blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false,
+ PREALLOC_MODE_OFF, 0, errp);
if (ret < 0) {
goto exit;
}
@@ -2252,8 +2253,8 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize,
bool flat, bool compress,
i < gt_count; i++, tmp += gt_size) {
gd_buf[i] = cpu_to_le32(tmp);
}
- ret = blk_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
- gd_buf_size, gd_buf, 0);
+ ret = blk_co_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
+ gd_buf_size, gd_buf, 0);
if (ret < 0) {
error_setg(errp, QERR_IO_ERROR);
goto exit;
@@ -2264,8 +2265,8 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize,
bool flat, bool compress,
i < gt_count; i++, tmp += gt_size) {
gd_buf[i] = cpu_to_le32(tmp);
}
- ret = blk_pwrite(blk, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
- gd_buf_size, gd_buf, 0);
+ ret = blk_co_pwrite(blk, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
+ gd_buf_size, gd_buf, 0);
if (ret < 0) {
error_setg(errp, QERR_IO_ERROR);
}
--
2.41.0
- [PULL 04/23] block: Fix AioContext locking in bdrv_open_child(), (continued)
- [PULL 04/23] block: Fix AioContext locking in bdrv_open_child(), Kevin Wolf, 2023/06/28
- [PULL 07/23] block: Fix AioContext locking in bdrv_open_inherit(), Kevin Wolf, 2023/06/28
- [PULL 02/23] qdev-properties-system: Lock AioContext for blk_insert_bs(), Kevin Wolf, 2023/06/28
- [PULL 05/23] block: Fix AioContext locking in bdrv_attach_child_common(), Kevin Wolf, 2023/06/28
- [PULL 14/23] vpc: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 09/23] blockjob: Fix AioContext locking in block_job_add_bdrv(), Kevin Wolf, 2023/06/28
- [PULL 20/23] vhdx: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 11/23] Revert "graph-lock: Disable locking for now", Kevin Wolf, 2023/06/28
- [PULL 10/23] graph-lock: Unlock the AioContext while polling, Kevin Wolf, 2023/06/28
- [PULL 21/23] qcow2: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 19/23] vmdk: mark more functions as coroutine_fns and GRAPH_RDLOCK,
Kevin Wolf <=
- [PULL 03/23] test-block-iothread: Lock AioContext for blk_insert_bs(), Kevin Wolf, 2023/06/28
- [PULL 08/23] block: Fix AioContext locking in bdrv_open_backing_file(), Kevin Wolf, 2023/06/28
- [PULL 16/23] block: mark another function as coroutine_fns and GRAPH_UNLOCKED, Kevin Wolf, 2023/06/28
- [PULL 17/23] cloop: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 12/23] file-posix: remove incorrect coroutine_fn calls, Kevin Wolf, 2023/06/28
- [PULL 13/23] qed: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 06/23] block: Fix AioContext locking in bdrv_reopen_parse_file_or_backing(), Kevin Wolf, 2023/06/28
- [PULL 15/23] bochs: mark more functions as coroutine_fns and GRAPH_RDLOCK, Kevin Wolf, 2023/06/28
- [PULL 23/23] block: use bdrv_co_debug_event in coroutine context, Kevin Wolf, 2023/06/28
- [PULL 22/23] block: use bdrv_co_getlength in coroutine context, Kevin Wolf, 2023/06/28