From nobody Mon Sep 28 02:08:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1785431518; cv=none; d=zohomail.com; s=zohoarc; b=YduOHf7AJK9eQ3uzIQwLCEf0qZSHhb7xxKDQzg6XpNHVwAjpL6q85ZU0JA/bm06MPnjnvX0wteQk9/6sMHfAbegScaBvQ2AHMA/LkKOdXjBG6YT16yehF2P1IrLGi6dPLZZwfKYZaoZLu/CsCmC3Z5HkCytIPxjDLRjnGfV/7KA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785431518; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d1Byx+6PIj8v3r8ZThcZLAUtUiaA1rUtsyNE1SNFRHQ=; b=LeoRdt52Cyq4rll81xOTIUGsIpqMORSGlN9QrdrF2vcXLHPY9+dK4y4x5WQH6O5wiih+H1zMio8H58KWKZycqNZAxrZpKqWiSaTDMTHiHnUyketnyfo2qwzZWOUTqWs3/JBr38EfOcU2Z+M5dn2RdgpjfMd+yg57DVNkjQ8Re7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785431518060699.2190231721; Thu, 30 Jul 2026 10:11:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpUHf-0002oW-Va; Thu, 30 Jul 2026 13:11:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpUHL-0002ns-HK for qemu-devel@nongnu.org; Thu, 30 Jul 2026 13:10:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpUHJ-0005j1-Bd for qemu-devel@nongnu.org; Thu, 30 Jul 2026 13:10:43 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-OidVTywhOH-VF4whvZr1Nw-1; Thu, 30 Jul 2026 13:10:36 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C815A19560A1; Thu, 30 Jul 2026 17:10:34 +0000 (UTC) Received: from localhost (unknown [10.44.24.15]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B6A8119560AB; Thu, 30 Jul 2026 17:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785431439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1Byx+6PIj8v3r8ZThcZLAUtUiaA1rUtsyNE1SNFRHQ=; b=SDsYb61MowytL7491gMSQItBN2okRkmBCS8ThlHwkHNZQVN21UDtHF4IWsiYqJKJKYZ5A7 Zo2vCXRr3uUd/LYxikAtFvXgpWOUah+pacb1CigxVMLocddtp3aQSMNLFaUZuZdPIdh0E/ dGZyZwDqXpK7jfswrwzV/KNSk68081o= X-MC-Unique: OidVTywhOH-VF4whvZr1Nw-1 X-Mimecast-MFC-AGG-ID: OidVTywhOH-VF4whvZr1Nw_1785431435 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Hanna Reitz , Fam Zheng , John Snow , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org (open list:Block layer core) Subject: [PATCH v3] block: add missing coroutine_fn annotations Date: Thu, 30 Jul 2026 21:10:26 +0400 Message-ID: <20260730171027.1023696-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.58, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1785431520712158500 From: Marc-Andr=C3=A9 Lureau 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=C3=A9 Lureau --- 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); =20 /** * 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(QCryptoBlockForma= t format, } =20 =20 -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 =3D opaque; BlockCrypto *crypto =3D 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(BlockDr= iverState *bs, assert(data.done); } =20 -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(); =20 @@ -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(); =20 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: } =20 /* 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 =3D bs->opaque; int i; @@ -1299,6 +1300,7 @@ static void qcow2_update_options_commit(BlockDriverSt= ate *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); =20 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); } =20 -void block_job_ratelimit_sleep(BlockJob *job) +void coroutine_fn +block_job_ratelimit_sleep(BlockJob *job) { uint64_t delay_ns; =20 --=20 2.55.0