* [PATCH v3] block: add missing coroutine_fn annotations
@ 2026-07-30 17:10 marcandre.lureau
2026-11-06 8:16 ` Marc-André Lureau
2026-11-06 12:47 ` Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: marcandre.lureau @ 2026-07-30 17:10 UTC (permalink / raw)
To: qemu-devel
Cc: stefanha, kwolf, Marc-André Lureau, Hanna Reitz, Fam Zheng,
John Snow, Vladimir Sementsov-Ogievskiy,
open list:Block layer core
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The functions call coroutine functions or are called by coroutine.
Add an assert() in qcow2_do_close() code path which calls a
no_coroutine_fn bdrv_graph_wrlock_drained().
Add an assert() in qcow2_update_options_commit() in the coroutine
path.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
v3:
- remove indentiation changes leftovers
---
include/block/blockjob_int.h | 2 +-
block/crypto.c | 13 +++++++------
block/io.c | 8 +++++---
block/qcow2.c | 9 ++++++---
blockjob.c | 3 ++-
5 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
index 4c3d2e25a209..34e172874fa9 100644
--- a/include/block/blockjob_int.h
+++ b/include/block/blockjob_int.h
@@ -150,7 +150,7 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n);
* Put the job to sleep (assuming that it wasn't canceled) to throttle it to the
* right speed according to its rate limiting.
*/
-void block_job_ratelimit_sleep(BlockJob *job);
+void coroutine_fn block_job_ratelimit_sleep(BlockJob *job);
/**
* block_job_error_action:
diff --git a/block/crypto.c b/block/crypto.c
index 36abb7af4680..8a34d92fded6 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -56,12 +56,13 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
}
-static int block_crypto_read_func(QCryptoBlock *block,
- size_t offset,
- uint8_t *buf,
- size_t buflen,
- void *opaque,
- Error **errp)
+static int coroutine_mixed_fn
+block_crypto_read_func(QCryptoBlock *block,
+ size_t offset,
+ uint8_t *buf,
+ size_t buflen,
+ void *opaque,
+ Error **errp)
{
BlockDriverState *bs = opaque;
BlockCrypto *crypto = bs->opaque;
diff --git a/block/io.c b/block/io.c
index a916b236c3c8..99dd16864a3d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -346,8 +346,9 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
assert(data.done);
}
-static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
- bool poll)
+static void coroutine_mixed_fn
+bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
+ bool poll)
{
IO_OR_GS_CODE();
@@ -397,7 +398,8 @@ bdrv_drained_begin(BlockDriverState *bs)
* This function does not poll, nor must any of its recursively called
* functions.
*/
-static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
+static void coroutine_mixed_fn
+bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
{
IO_OR_GS_CODE();
diff --git a/block/qcow2.c b/block/qcow2.c
index 19271b10a49f..03526c4a131f 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1287,9 +1287,10 @@ fail:
}
/* s_locked specifies whether s->lock is held or not */
-static void qcow2_update_options_commit(BlockDriverState *bs,
- Qcow2ReopenState *r,
- bool s_locked)
+static coroutine_mixed_fn void
+qcow2_update_options_commit(BlockDriverState *bs,
+ Qcow2ReopenState *r,
+ bool s_locked)
{
BDRVQcow2State *s = bs->opaque;
int i;
@@ -1299,6 +1300,7 @@ static void qcow2_update_options_commit(BlockDriverState *bs,
* table caches
*/
if (s_locked) {
+ assert(qemu_in_coroutine());
cache_clean_timer_co_locked_del_and_wait(bs);
} else {
cache_clean_timer_del_and_wait(bs);
@@ -2905,6 +2907,7 @@ qcow2_do_close(BlockDriverState *bs, bool close_data_file)
g_free(s->image_backing_format);
if (close_data_file && has_data_file(bs)) {
+ assert(!qemu_in_coroutine());
GLOBAL_STATE_CODE();
bdrv_graph_rdunlock_main_loop();
bdrv_graph_wrlock_drained();
diff --git a/blockjob.c b/blockjob.c
index f3b11cc7a194..f3ad6a93125a 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -338,7 +338,8 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n)
ratelimit_calculate_delay(&job->limit, n);
}
-void block_job_ratelimit_sleep(BlockJob *job)
+void coroutine_fn
+block_job_ratelimit_sleep(BlockJob *job)
{
uint64_t delay_ns;
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] block: add missing coroutine_fn annotations
2026-07-30 17:10 [PATCH v3] block: add missing coroutine_fn annotations marcandre.lureau
@ 2026-11-06 8:16 ` Marc-André Lureau
2026-11-06 12:47 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2026-11-06 8:16 UTC (permalink / raw)
To: qemu-devel
Cc: stefanha, kwolf, Hanna Reitz, Fam Zheng, John Snow,
Vladimir Sementsov-Ogievskiy, open list:Block layer core
On Thu, Jul 30, 2026 at 9:12 PM <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The functions call coroutine functions or are called by coroutine.
>
> Add an assert() in qcow2_do_close() code path which calls a
> no_coroutine_fn bdrv_graph_wrlock_drained().
>
> Add an assert() in qcow2_update_options_commit() in the coroutine
> path.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
ping
> ---
> v3:
> - remove indentiation changes leftovers
> ---
> include/block/blockjob_int.h | 2 +-
> block/crypto.c | 13 +++++++------
> block/io.c | 8 +++++---
> block/qcow2.c | 9 ++++++---
> blockjob.c | 3 ++-
> 5 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
> index 4c3d2e25a209..34e172874fa9 100644
> --- a/include/block/blockjob_int.h
> +++ b/include/block/blockjob_int.h
> @@ -150,7 +150,7 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n);
> * Put the job to sleep (assuming that it wasn't canceled) to throttle it to the
> * right speed according to its rate limiting.
> */
> -void block_job_ratelimit_sleep(BlockJob *job);
> +void coroutine_fn block_job_ratelimit_sleep(BlockJob *job);
>
> /**
> * block_job_error_action:
> diff --git a/block/crypto.c b/block/crypto.c
> index 36abb7af4680..8a34d92fded6 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -56,12 +56,13 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
> }
>
>
> -static int block_crypto_read_func(QCryptoBlock *block,
> - size_t offset,
> - uint8_t *buf,
> - size_t buflen,
> - void *opaque,
> - Error **errp)
> +static int coroutine_mixed_fn
> +block_crypto_read_func(QCryptoBlock *block,
> + size_t offset,
> + uint8_t *buf,
> + size_t buflen,
> + void *opaque,
> + Error **errp)
> {
> BlockDriverState *bs = opaque;
> BlockCrypto *crypto = bs->opaque;
> diff --git a/block/io.c b/block/io.c
> index a916b236c3c8..99dd16864a3d 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -346,8 +346,9 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
> assert(data.done);
> }
>
> -static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
> - bool poll)
> +static void coroutine_mixed_fn
> +bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
> + bool poll)
> {
> IO_OR_GS_CODE();
>
> @@ -397,7 +398,8 @@ bdrv_drained_begin(BlockDriverState *bs)
> * This function does not poll, nor must any of its recursively called
> * functions.
> */
> -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
> +static void coroutine_mixed_fn
> +bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
> {
> IO_OR_GS_CODE();
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 19271b10a49f..03526c4a131f 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1287,9 +1287,10 @@ fail:
> }
>
> /* s_locked specifies whether s->lock is held or not */
> -static void qcow2_update_options_commit(BlockDriverState *bs,
> - Qcow2ReopenState *r,
> - bool s_locked)
> +static coroutine_mixed_fn void
> +qcow2_update_options_commit(BlockDriverState *bs,
> + Qcow2ReopenState *r,
> + bool s_locked)
> {
> BDRVQcow2State *s = bs->opaque;
> int i;
> @@ -1299,6 +1300,7 @@ static void qcow2_update_options_commit(BlockDriverState *bs,
> * table caches
> */
> if (s_locked) {
> + assert(qemu_in_coroutine());
> cache_clean_timer_co_locked_del_and_wait(bs);
> } else {
> cache_clean_timer_del_and_wait(bs);
> @@ -2905,6 +2907,7 @@ qcow2_do_close(BlockDriverState *bs, bool close_data_file)
> g_free(s->image_backing_format);
>
> if (close_data_file && has_data_file(bs)) {
> + assert(!qemu_in_coroutine());
> GLOBAL_STATE_CODE();
> bdrv_graph_rdunlock_main_loop();
> bdrv_graph_wrlock_drained();
> diff --git a/blockjob.c b/blockjob.c
> index f3b11cc7a194..f3ad6a93125a 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -338,7 +338,8 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n)
> ratelimit_calculate_delay(&job->limit, n);
> }
>
> -void block_job_ratelimit_sleep(BlockJob *job)
> +void coroutine_fn
> +block_job_ratelimit_sleep(BlockJob *job)
> {
> uint64_t delay_ns;
>
> --
> 2.55.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] block: add missing coroutine_fn annotations
2026-07-30 17:10 [PATCH v3] block: add missing coroutine_fn annotations marcandre.lureau
2026-11-06 8:16 ` Marc-André Lureau
@ 2026-11-06 12:47 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2026-11-06 12:47 UTC (permalink / raw)
To: marcandre.lureau
Cc: qemu-devel, stefanha, Hanna Reitz, Fam Zheng, John Snow,
Vladimir Sementsov-Ogievskiy, open list:Block layer core
Am 30.07.2026 um 19:10 hat marcandre.lureau@redhat.com geschrieben:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The functions call coroutine functions or are called by coroutine.
>
> Add an assert() in qcow2_do_close() code path which calls a
> no_coroutine_fn bdrv_graph_wrlock_drained().
>
> Add an assert() in qcow2_update_options_commit() in the coroutine
> path.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-06 12:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 17:10 [PATCH v3] block: add missing coroutine_fn annotations marcandre.lureau
2026-11-06 8:16 ` Marc-André Lureau
2026-11-06 12:47 ` Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.