[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/23] dmg: mark more functions as coroutine_fns and GRAPH_RDLOCK
From: |
Kevin Wolf |
Subject: |
[PULL 18/23] dmg: mark more functions as coroutine_fns and GRAPH_RDLOCK |
Date: |
Wed, 28 Jun 2023 16:15:21 +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-8-pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/dmg.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/block/dmg.c b/block/dmg.c
index 2769900359..06a0244a9c 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -616,7 +616,8 @@ err:
return s->n_chunks; /* error */
}
-static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
+static int coroutine_fn GRAPH_RDLOCK
+dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
{
BDRVDMGState *s = bs->opaque;
@@ -633,8 +634,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs,
uint64_t sector_num)
case UDZO: { /* zlib compressed */
/* we need to buffer, because only the chunk as whole can be
* inflated. */
- ret = bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
- s->compressed_chunk, 0);
+ ret = bdrv_co_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
+ s->compressed_chunk, 0);
if (ret < 0) {
return -1;
}
@@ -659,8 +660,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs,
uint64_t sector_num)
}
/* we need to buffer, because only the chunk as whole can be
* inflated. */
- ret = bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
- s->compressed_chunk, 0);
+ ret = bdrv_co_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
+ s->compressed_chunk, 0);
if (ret < 0) {
return -1;
}
@@ -680,8 +681,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs,
uint64_t sector_num)
}
/* we need to buffer, because only the chunk as whole can be
* inflated. */
- ret = bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
- s->compressed_chunk, 0);
+ ret = bdrv_co_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
+ s->compressed_chunk, 0);
if (ret < 0) {
return -1;
}
@@ -696,8 +697,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs,
uint64_t sector_num)
}
break;
case UDRW: /* copy */
- ret = bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
- s->uncompressed_chunk, 0);
+ ret = bdrv_co_pread(bs->file, s->offsets[chunk], s->lengths[chunk],
+ s->uncompressed_chunk, 0);
if (ret < 0) {
return -1;
}
@@ -713,7 +714,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs,
uint64_t sector_num)
return 0;
}
-static int coroutine_fn
+static int coroutine_fn GRAPH_RDLOCK
dmg_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, BdrvRequestFlags flags)
{
--
2.41.0
- [PULL 03/23] test-block-iothread: Lock AioContext for blk_insert_bs(), (continued)
- [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
- [PULL 18/23] dmg: mark more functions as coroutine_fns and GRAPH_RDLOCK,
Kevin Wolf <=
- Re: [PULL 00/23] Block layer patches, Richard Henderson, 2023/06/29