From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620423; cv=none; d=zohomail.com; s=zohoarc; b=dUM4NlmCzaICzlaxxOi+RJzMZZfbq2SCLrUdWiI1VMSnBqZuvjaCeZoDFAu/aQj1/gedohYK7ENlFa4D+WomWLg4udfsfTx7CPbt+pFJLynF2914LWXLjICU4RkRpk9D8upspCXfNO2ac5ZAPjy3rxeHMY3J/iQT3/E3jLy6GH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620423; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iMWulZHTaScQd9/JU/TApJQLCHaMO0Wjq3Q9vGaYfHU=; b=mp/XTugMK6e1Z5oNy213Opa3pFWwFl5cWhnGh0sBsMc+xgrNur99YifvtPsSHwSxS4W78dGiBX6tOKXqB28ZX7H86dGX+rPK1tuTG7DRPg0FKbPGr47nn61oKpnuURj9VejYsG23f8gyceUaTVV05J3xxvDth6lwKah7EIgDLAc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620423800807.3095432337601; Thu, 1 Jun 2023 04:53:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqS-0000jq-G9; Thu, 01 Jun 2023 07:51:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqP-0000Wr-Oe for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqO-0000JH-18 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:53 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-zMNzUBFnNzyf2wUMBTAsMg-1; Thu, 01 Jun 2023 07:51:50 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-96f4d917e06so249380066b.1 for ; Thu, 01 Jun 2023 04:51:49 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id f26-20020a170906561a00b009664e25c425sm10558794ejq.95.2023.06.01.04.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620311; 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: in-reply-to:in-reply-to:references:references; bh=iMWulZHTaScQd9/JU/TApJQLCHaMO0Wjq3Q9vGaYfHU=; b=JlUOC+ZdN3qTLJ4TbjCvNhmOpqbT5jbwlmAIFRbxeIiW7zAdbatjczz76FFBymNglpueGg HnwepURF0CO5oVcgObfdaAwLNr800kH98fxhlT+hrfrvWcrW1ieFmVbRYQck6x3/gXx/vC 6IJqd+vFulIV+o2oeXe8WL0ZbqTnWt0= X-MC-Unique: zMNzUBFnNzyf2wUMBTAsMg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620308; x=1688212308; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iMWulZHTaScQd9/JU/TApJQLCHaMO0Wjq3Q9vGaYfHU=; b=fjCbUnnY+Xs0VFhdSjiFVNVZuGEpt56jK1Hkk+3Q1ZlDQ8zeeAArrjBw8JgahAh7pF WmJgpzvsWlrxB1HadH8+BcmMCC268wGEwJWFzPw1tZh3I97iRbqjI5qH5OOFPqgyw23k 0HlGPnD/GGP0hm5zeQNrNbaGka7zsrIhY9N1D2OMtVcoZ2UoOBmtBGqg2fZgZbCVuOob J4cQqeGU7i90ynIidabmN/UMmBfcPRVta6JVwCsMgAokMww8oTUmfVOqJZbBSas/zRsq AGcHO65g4QNm7xj/xq/y6arNJc4rE5IehptI+BQamgv5aEyjKUYUuQ4jDZLJ/NZttZMM Gq+w== X-Gm-Message-State: AC+VfDw7jTASFs45dzt886ygsBK3s6+sF3NB6QKYO9u1DRiK21/EASKA wSPE0A3U5rnAOXZG/rVCE9Vj5Iurgh82CLmDiiT9yEv/ICe7LlPAdODUzSRW6/QRSJc8sBzNq0i SKylgq/AAcseMrFew9XYJfBhSQ8SPp3PODUOzkPjlD5MkvNrn4YF2Xjun5YbQ5IiTz+N950ZLU4 o= X-Received: by 2002:a17:907:9445:b0:973:84b0:b077 with SMTP id dl5-20020a170907944500b0097384b0b077mr1379959ejc.33.1685620308679; Thu, 01 Jun 2023 04:51:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5q6mOFXZ5qDaaNBM34xR8MAFtmYRDWlkHbcC7yg+C8gMTlR/lLhGueChez+D0/QCux86Y0Bw== X-Received: by 2002:a17:907:9445:b0:973:84b0:b077 with SMTP id dl5-20020a170907944500b0097384b0b077mr1379942ejc.33.1685620308416; Thu, 01 Jun 2023 04:51:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 01/12] file-posix: remove incorrect coroutine_fn calls Date: Thu, 1 Jun 2023 13:51:34 +0200 Message-Id: <20230601115145.196465-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620424907100002 Content-Type: text/plain; charset="utf-8" raw_co_getlength is called by handle_aiocb_write_zeroes, which is not a cor= outine function. This is harmless because raw_co_getlength does not actually susp= end, but in the interest of clarity make it a non-coroutine_fn that is just wrap= ped by the coroutine_fn raw_co_getlength. Likewise, check_cache_dropped was on= ly a coroutine_fn because it called raw_co_getlength, so it can be made non-co= routine as well. Signed-off-by: Paolo Bonzini --- block/file-posix.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 942f529f6ffc..5e0afaba69a5 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -193,7 +193,7 @@ static int fd_open(BlockDriverState *bs) return -EIO; } =20 -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs); +static int64_t raw_getlength(BlockDriverState *bs); =20 typedef struct RawPosixAIOData { BlockDriverState *bs; @@ -1974,7 +1974,7 @@ static int handle_aiocb_write_zeroes(void *opaque) #ifdef CONFIG_FALLOCATE /* Last resort: we are trying to extend the file with zeroed data. This * can be done via fallocate(fd, 0) */ - len =3D raw_co_getlength(aiocb->bs); + len =3D raw_getlength(aiocb->bs); if (s->has_fallocate && len >=3D 0 && aiocb->aio_offset >=3D len) { int ret =3D do_fallocate(s->fd, 0, aiocb->aio_offset, aiocb->aio_n= bytes); if (ret =3D=3D 0 || ret !=3D -ENOTSUP) { @@ -2696,7 +2696,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverSt= ate *bs, int64_t offset, } =20 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { - int64_t cur_length =3D raw_co_getlength(bs); + int64_t cur_length =3D raw_getlength(bs); =20 if (offset !=3D cur_length && exact) { error_setg(errp, "Cannot resize device files"); @@ -2714,7 +2714,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverSt= ate *bs, int64_t offset, } =20 #ifdef __OpenBSD__ -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; int fd =3D s->fd; @@ -2733,7 +2733,7 @@ static int64_t coroutine_fn raw_co_getlength(BlockDri= verState *bs) return st.st_size; } #elif defined(__NetBSD__) -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; int fd =3D s->fd; @@ -2758,7 +2758,7 @@ static int64_t coroutine_fn raw_co_getlength(BlockDri= verState *bs) return st.st_size; } #elif defined(__sun__) -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; struct dk_minfo minfo; @@ -2789,7 +2789,7 @@ static int64_t coroutine_fn raw_co_getlength(BlockDri= verState *bs) return size; } #elif defined(CONFIG_BSD) -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; int fd =3D s->fd; @@ -2861,7 +2861,7 @@ again: return size; } #else -static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; int ret; @@ -2880,6 +2880,11 @@ static int64_t coroutine_fn raw_co_getlength(BlockDr= iverState *bs) } #endif =20 +static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) +{ + return raw_getlength(bs); +} + static int64_t coroutine_fn raw_co_get_allocated_file_size(BlockDriverStat= e *bs) { struct stat st; @@ -3245,7 +3250,7 @@ static int coroutine_fn raw_co_block_status(BlockDriv= erState *bs, * round up if necessary. */ if (!QEMU_IS_ALIGNED(*pnum, bs->bl.request_alignment)) { - int64_t file_length =3D raw_co_getlength(bs); + int64_t file_length =3D raw_getlength(bs); if (file_length > 0) { /* Ignore errors, this is just a safeguard */ assert(hole =3D=3D file_length); @@ -3267,7 +3272,7 @@ static int coroutine_fn raw_co_block_status(BlockDriv= erState *bs, =20 #if defined(__linux__) /* Verify that the file is not in the page cache */ -static void coroutine_fn check_cache_dropped(BlockDriverState *bs, Error *= *errp) +static void check_cache_dropped(BlockDriverState *bs, Error **errp) { const size_t window_size =3D 128 * 1024 * 1024; BDRVRawState *s =3D bs->opaque; @@ -3282,7 +3287,7 @@ static void coroutine_fn check_cache_dropped(BlockDri= verState *bs, Error **errp) page_size =3D sysconf(_SC_PAGESIZE); vec =3D g_malloc(DIV_ROUND_UP(window_size, page_size)); =20 - end =3D raw_co_getlength(bs); + end =3D raw_getlength(bs); =20 for (offset =3D 0; offset < end; offset +=3D window_size) { void *new_window; @@ -4504,7 +4509,7 @@ static int cdrom_reopen(BlockDriverState *bs) =20 static bool coroutine_fn cdrom_co_is_inserted(BlockDriverState *bs) { - return raw_co_getlength(bs) > 0; + return raw_getlength(bs) > 0; } =20 static void coroutine_fn cdrom_co_eject(BlockDriverState *bs, bool eject_f= lag) --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620550; cv=none; d=zohomail.com; s=zohoarc; b=Aihhr9YJFYhjr+A3L326fXMngeku4kXe/Nm16uxD0tAtjByQDX8sXjlLFkgYX4s+ujmwaOKwiNESn8GxZOwBjYYOXigjTHTRRCregJ6T2z3pqlz/s9k2hrL2zLEahAE/X9OlqnCyAMRyjELHPzUfYtztPUJIAWaxUfKIOOTH0qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620550; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zTnSEqDBVt1yhSZOW2KDdJhR08dElUQEsWstYjHBXcc=; b=Mq5eDjBYmacUN3irgCqVnrCcOwPW0Uj36guIWZsAubloC5T2pdkh448S4zuM2S/SbC51bfoph5JkI9i/YvB+EzwXyTBBS5wPz9QL08rKS59YtZXT1Rpv/qvIBeTZMtHfvezhSW0Dc1msgrbM71g+2h394KbVGknhZZAb3TfdM/E= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168562055047054.17535062488889; Thu, 1 Jun 2023 04:55:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqT-0000lW-Vl; Thu, 01 Jun 2023 07:51:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqS-0000jI-75 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqP-0000Jl-Ce for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:54 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-MqUi__lGPTe0MTs50xm1tg-1; Thu, 01 Jun 2023 07:51:51 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96f4d917e06so249383266b.1 for ; Thu, 01 Jun 2023 04:51:51 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id lt16-20020a170906fa9000b00973f1cd586fsm6747865ejb.1.2023.06.01.04.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620312; 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: in-reply-to:in-reply-to:references:references; bh=zTnSEqDBVt1yhSZOW2KDdJhR08dElUQEsWstYjHBXcc=; b=Vf9HGbsv6/PxyrP5Xf4fA3il1U3yQ8fjETDm7iAII2+4m+DnzZdzpiKPcIrATGUzCBe7jT 6C2PAPDCdlnhdxEf5/1sj0AphLGgfEUw/ZiL7410Q9Ool5qDB9XP/R+C1vGa4sLh++2Dzu WjAHzqgSvfw6V4kIHgTdg3NDpPRCAlY= X-MC-Unique: MqUi__lGPTe0MTs50xm1tg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620310; x=1688212310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zTnSEqDBVt1yhSZOW2KDdJhR08dElUQEsWstYjHBXcc=; b=kYMJ8rlWUEToVY1P0muSzAzofSU2S5uXdB2Ha83WlWx/wW45m1nuptPDUGMLrU2jHL jZ9OdMpPAQ2xhKaSqK7JNbNs069soT+AulbL1cIJPE2Csa0cYmut0vOiTBykiuyqcPHV ynUxZjjonw9S9YwyArdfclnhTwF6S1EBwmXKSuFUUYRi7IXlSBP7e5kvcBminTfEX92L wWT8/Mtq16rAZgzT9b3rQ3axt1rj/3jfjojiDtKO6f5sFoUCDKrqDbWXJEFYjvEpPrM/ xSSfMTTZVcbw+4GFDBVdIfI9a2hQspyWYI2OSCib5u20OKLFXDqmPBSEsls4Wjq/MbK0 qQ3Q== X-Gm-Message-State: AC+VfDzW0KHey4vxRD/1wgpXZl07QqwTZjGgK9aX8SEEDVsE8K6PEiCu RIkjHHnEMor1/GbT26NibtVUh11I3kGE0K5t5R4FeTXXLPzDNwEREJQLpHeG6vcQ7WFeDHYZ9ng xgjEZyWJsHrNDV/smxUQ/LxXZHDT5wkO/jXUtqWhRoFXJW3i8X6JHoLJMykf1Q4ylrOK3Q88Oj2 w= X-Received: by 2002:a17:907:7ea4:b0:96f:d04c:1d84 with SMTP id qb36-20020a1709077ea400b0096fd04c1d84mr1458996ejc.12.1685620310228; Thu, 01 Jun 2023 04:51:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zlD1h9jOAz6d1mvQR9rSI7v/x2xw8ooXL4LrAPorgye4C9ccuF0taDPmvmaWpMHb3sovn1w== X-Received: by 2002:a17:907:7ea4:b0:96f:d04c:1d84 with SMTP id qb36-20020a1709077ea400b0096fd04c1d84mr1458977ejc.12.1685620309978; Thu, 01 Jun 2023 04:51:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 02/12] qed: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:35 +0200 Message-Id: <20230601115145.196465-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620551506100005 Content-Type: text/plain; charset="utf-8" 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 --- block/qed-check.c | 5 +++-- block/qed.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block/qed-check.c b/block/qed-check.c index 8fd94f405ed7..6a01b94f9c9c 100644 --- a/block/qed-check.c +++ b/block/qed-check.c @@ -200,7 +200,8 @@ static void qed_check_for_leaks(QEDCheck *check) /** * Mark an image clean once it passes check or has been repaired */ -static void qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result) +static void coroutine_fn GRAPH_RDLOCK +qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result) { /* Skip if there were unfixable corruptions or I/O errors */ if (result->corruptions > 0 || result->check_errors > 0) { @@ -213,7 +214,7 @@ static void qed_check_mark_clean(BDRVQEDState *s, BdrvC= heckResult *result) } =20 /* Ensure fixes reach storage before clearing check bit */ - bdrv_flush(s->bs); + bdrv_co_flush(s->bs); =20 s->header.features &=3D ~QED_F_NEED_CHECK; qed_write_header_sync(s); diff --git a/block/qed.c b/block/qed.c index 8e08f89bbd01..382c05c83fef 100644 --- a/block/qed.c +++ b/block/qed.c @@ -195,14 +195,15 @@ static bool qed_is_image_size_valid(uint64_t image_si= ze, uint32_t cluster_size, * * The string is NUL-terminated. */ -static int qed_read_string(BdrvChild *file, uint64_t offset, size_t n, - char *buf, size_t buflen) +static int coroutine_fn GRAPH_RDLOCK +qed_read_string(BdrvChild *file, uint64_t offset, + size_t n, char *buf, size_t buflen) { int ret; if (n >=3D buflen) { return -EINVAL; } - ret =3D bdrv_pread(file, offset, n, buf, 0); + ret =3D bdrv_co_pread(file, offset, n, buf, 0); if (ret < 0) { return ret; } --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620494; cv=none; d=zohomail.com; s=zohoarc; b=eM0R/AsS9PzsXsoc97Svpv6SiwKVh3F9uBZGrfFILPupjS8+P1UAg5UWGj75/qIO6kWqNKoWnkkGrT9x904mdYicoaZ7hz3KbE6KZZ1I/eTztiJ3b2nCieGae2WdGdvObWjPdNtWNS37XDoFNqZ/lswWmzuReOYzgEeZeYEXzDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1+15Ues+9N1LiEnG5bYhMWTuA1nqCGUfqQ757hiAsyk=; b=BNhNwq9o4+SazvpSngL5OFfHI8FHoXvdmNTbRLt6RUJhPlW3VD1GlCDmLLfvUJtFqRRyyS1ehcQyPK43dyZtOrqH8IDPxSObBagkIjhDGOXeV23q0T5aL2z4XyODJPBobbifjx6GnrAC++wMcj3sY2xKpY01WAIu6mRcQmk4hsE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620494059788.7174259629519; Thu, 1 Jun 2023 04:54:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqb-0001Ag-9l; Thu, 01 Jun 2023 07:52:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqV-0000mS-Gq for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqT-0000Kg-0I for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:59 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-478-G3eVb2g_Pdms89E9akWYcA-1; Thu, 01 Jun 2023 07:51:53 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-96fd3757c1dso47784466b.1 for ; Thu, 01 Jun 2023 04:51:53 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id j6-20020aa7c0c6000000b00514b2a9ce60sm3227553edp.81.2023.06.01.04.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620314; 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: in-reply-to:in-reply-to:references:references; bh=1+15Ues+9N1LiEnG5bYhMWTuA1nqCGUfqQ757hiAsyk=; b=ORRImjy5hKGPE7OmPZGOLuXEKvGFqtxI7qcouX+nscu5ADhEmanLu27+DkRYJjOZRiv78p fEcGOr0Fjhspbk0JtoSmB3GFpb56XX+LRRFQY+dstMgqXY2Ud+umq4+eds3RtIxnN7ICuS 1z2xUBrUIayKmi9mRSfKxSK1WpwgDZk= X-MC-Unique: G3eVb2g_Pdms89E9akWYcA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620312; x=1688212312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1+15Ues+9N1LiEnG5bYhMWTuA1nqCGUfqQ757hiAsyk=; b=KldHUl2Rxrl1zQqTN6jMDotSYYUxmVqOGYtDIqFpvZE38exhzckO0q66KrdTB9nPgi VMbubYeXr37/YzgZNi/7WJdYk0dEZknujQEGmBjMpdkwRgAA4wG6Rs2VsnTvFNbleWKH U6LEvf9N1f2hO03M+1cbW5Nek0zfeLjC7oKIeb3GarcnwSv0dkBvcPnsedTPK6BjRaIN wYCa8NUtx9TComv6kDTmCIGmur5l8YoM0Pct2Af7B/Ccf4kBQAdv52lUAdjgycUtn8UN 8riG4GyO/x9qlmTYY9kZskZ9HlO5mngu3zwW/FLLqrDPcyV0/xuI1ANrjCcuc1ZDly+c qTTQ== X-Gm-Message-State: AC+VfDzow5sWB5xR96cXvHwViKHb+rH3nODinfPFvEdviUcxYo6sgrkW N60zYY6TbrjmQQejQvg2uR+PY0dBPh+6J+engasPsbj1/FQ4fot7Yv+WpL2DJDw9CsHrPs8i3OK 2Jx2tT/cfUqm8JN9xvSN5/Bc8P+6423DUgRC75tpdwAwiSjQVoPQB8fcCaBMhj1X59NQl3VSgBS o= X-Received: by 2002:a17:907:6da4:b0:96f:1f79:c0a6 with SMTP id sb36-20020a1709076da400b0096f1f79c0a6mr6940155ejc.70.1685620311826; Thu, 01 Jun 2023 04:51:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zAeb97uIiH4KXthuk9X/zImYSrTNf1zf+jeqtPQNmBmuT506LpUvxienze2zDbh0E09SBSw== X-Received: by 2002:a17:907:6da4:b0:96f:1f79:c0a6 with SMTP id sb36-20020a1709076da400b0096f1f79c0a6mr6940138ejc.70.1685620311554; Thu, 01 Jun 2023 04:51:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 03/12] vpc: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:36 +0200 Message-Id: <20230601115145.196465-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620495265100003 Content-Type: text/plain; charset="utf-8" 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 --- block/vpc.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 5af8e2807112..22a160267131 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -486,8 +486,8 @@ static int vpc_reopen_prepare(BDRVReopenState *state, * operation (the block bitmaps is updated then), 0 otherwise. * If write is true then err must not be NULL. */ -static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offs= et, - bool write, int *err) +static int64_t coroutine_fn GRAPH_RDLOCK +get_image_offset(BlockDriverState *bs, uint64_t offset, bool write, int *e= rr) { BDRVVPCState *s =3D bs->opaque; uint64_t bitmap_offset, block_offset; @@ -515,8 +515,7 @@ static inline int64_t get_image_offset(BlockDriverState= *bs, uint64_t offset, =20 s->last_bitmap_offset =3D bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); - r =3D bdrv_pwrite_sync(bs->file, bitmap_offset, s->bitmap_size, bi= tmap, - 0); + r =3D bdrv_co_pwrite_sync(bs->file, bitmap_offset, s->bitmap_size,= bitmap, 0); if (r < 0) { *err =3D r; return -2; @@ -532,13 +531,13 @@ static inline int64_t get_image_offset(BlockDriverSta= te *bs, uint64_t offset, * * Returns 0 on success and < 0 on error */ -static int rewrite_footer(BlockDriverState *bs) +static int coroutine_fn GRAPH_RDLOCK rewrite_footer(BlockDriverState *bs) { int ret; BDRVVPCState *s =3D bs->opaque; int64_t offset =3D s->free_data_block_offset; =20 - ret =3D bdrv_pwrite_sync(bs->file, offset, sizeof(s->footer), &s->foot= er, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, offset, sizeof(s->footer), &s->f= ooter, 0); if (ret < 0) return ret; =20 @@ -552,7 +551,8 @@ static int rewrite_footer(BlockDriverState *bs) * * Returns the sectors' offset in the image file on success and < 0 on err= or */ -static int64_t alloc_block(BlockDriverState *bs, int64_t offset) +static int64_t coroutine_fn GRAPH_RDLOCK +alloc_block(BlockDriverState *bs, int64_t offset) { BDRVVPCState *s =3D bs->opaque; int64_t bat_offset; @@ -572,8 +572,8 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) =20 /* Initialize the block's bitmap */ memset(bitmap, 0xff, s->bitmap_size); - ret =3D bdrv_pwrite_sync(bs->file, s->free_data_block_offset, - s->bitmap_size, bitmap, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, s->free_data_block_offset, + s->bitmap_size, bitmap, 0); if (ret < 0) { return ret; } @@ -587,7 +587,7 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) /* Write BAT entry to disk */ bat_offset =3D s->bat_offset + (4 * index); bat_value =3D cpu_to_be32(s->pagetable[index]); - ret =3D bdrv_pwrite_sync(bs->file, bat_offset, 4, &bat_value, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, bat_offset, 4, &bat_value, 0); if (ret < 0) goto fail; =20 @@ -718,11 +718,11 @@ fail: return ret; } =20 -static int coroutine_fn vpc_co_block_status(BlockDriverState *bs, - bool want_zero, - int64_t offset, int64_t bytes, - int64_t *pnum, int64_t *map, - BlockDriverState **file) +static int coroutine_fn GRAPH_RDLOCK +vpc_co_block_status(BlockDriverState *bs, bool want_zero, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) { BDRVVPCState *s =3D bs->opaque; int64_t image_offset; @@ -820,8 +820,8 @@ static int calculate_geometry(int64_t total_sectors, ui= nt16_t *cyls, return 0; } =20 -static int create_dynamic_disk(BlockBackend *blk, VHDFooter *footer, - int64_t total_sectors) +static int coroutine_fn create_dynamic_disk(BlockBackend *blk, VHDFooter *= footer, + int64_t total_sectors) { VHDDynDiskHeader dyndisk_header; uint8_t bat_sector[512]; @@ -834,13 +834,13 @@ static int create_dynamic_disk(BlockBackend *blk, VHD= Footer *footer, block_size =3D 0x200000; num_bat_entries =3D DIV_ROUND_UP(total_sectors, block_size / 512); =20 - ret =3D blk_pwrite(blk, offset, sizeof(*footer), footer, 0); + ret =3D blk_co_pwrite(blk, offset, sizeof(*footer), footer, 0); if (ret < 0) { goto fail; } =20 offset =3D 1536 + ((num_bat_entries * 4 + 511) & ~511); - ret =3D blk_pwrite(blk, offset, sizeof(*footer), footer, 0); + ret =3D blk_co_pwrite(blk, offset, sizeof(*footer), footer, 0); if (ret < 0) { goto fail; } @@ -850,7 +850,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFo= oter *footer, =20 memset(bat_sector, 0xFF, 512); for (i =3D 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) { - ret =3D blk_pwrite(blk, offset, 512, bat_sector, 0); + ret =3D blk_co_pwrite(blk, offset, 512, bat_sector, 0); if (ret < 0) { goto fail; } @@ -878,7 +878,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFo= oter *footer, /* Write the header */ offset =3D 512; =20 - ret =3D blk_pwrite(blk, offset, sizeof(dyndisk_header), &dyndisk_heade= r, 0); + ret =3D blk_co_pwrite(blk, offset, sizeof(dyndisk_header), &dyndisk_he= ader, 0); if (ret < 0) { goto fail; } @@ -888,21 +888,21 @@ static int create_dynamic_disk(BlockBackend *blk, VHD= Footer *footer, return ret; } =20 -static int create_fixed_disk(BlockBackend *blk, VHDFooter *footer, - int64_t total_size, Error **errp) +static int coroutine_fn create_fixed_disk(BlockBackend *blk, VHDFooter *fo= oter, + int64_t total_size, Error **errp) { int ret; =20 /* Add footer to total size */ total_size +=3D sizeof(*footer); =20 - ret =3D blk_truncate(blk, total_size, false, PREALLOC_MODE_OFF, 0, err= p); + ret =3D blk_co_truncate(blk, total_size, false, PREALLOC_MODE_OFF, 0, = errp); if (ret < 0) { return ret; } =20 - ret =3D blk_pwrite(blk, total_size - sizeof(*footer), sizeof(*footer), - footer, 0); + ret =3D blk_co_pwrite(blk, total_size - sizeof(*footer), sizeof(*foote= r), + footer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to write VHD header"); return ret; --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620548; cv=none; d=zohomail.com; s=zohoarc; b=PgIPaD3uU7NnYsfc0jthnd60c5hxV969//eeeK0+7Qbtap1++Hu79J5IRdWoK3W9dWaGUbB1QYkZC5QWg+u0gXLHfXW6tC/rmwOSmzTpFkiZKuxl6zie/kjZP62WY43KbDG/n8sMSFzRgzCh08lSiO1IVeNIJ2TbMH9Tn/cjn1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620548; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yLwJ0tgwKXkMFjE8GLsGzdve4xY6BIM2K13yGYNufvU=; b=LqBz5+QkSZ3AGyxo1qHe7G+pAPxz9dFy01swnLIKHrTkTJUnTr50EjstMbrS1EgIm5HwU39zNcb+5bD8d4MThWO1wgMILdRTAGj7rOk7CBdAElew8HrkH8dPdiTWLM6bDFM0owltMuCqjp2JmWhfofFkTwT/dhiwJzXdKYojwck= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620548768670.0293582425601; Thu, 1 Jun 2023 04:55:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqd-0001IO-8W; Thu, 01 Jun 2023 07:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqW-0000nG-3I for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:00 -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 1q4gqS-0000Kv-Hs for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:51:58 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-7XhHNZNePOyYWv92jLybIA-1; Thu, 01 Jun 2023 07:51:54 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9744659b7b5so55308566b.3 for ; Thu, 01 Jun 2023 04:51:54 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id j22-20020a1709062a1600b0096b1206aa3fsm10532251eje.89.2023.06.01.04.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620315; 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: in-reply-to:in-reply-to:references:references; bh=yLwJ0tgwKXkMFjE8GLsGzdve4xY6BIM2K13yGYNufvU=; b=hhBXKDn0Y+4vj6RRoVmN4zcG4+YR6sjGNeMc7MXMpYa+/19BxT8f9fEVYUdz9H19mVxL2Z KErIKhxV4jHPSt5FExypFt11scorJy4RsiWaEJJcq1TLrTQSrEF4w8eYWgQsbvIaW9oqiV yINmWmKFky2+EOOOIoxXaJJscYfSYEs= X-MC-Unique: 7XhHNZNePOyYWv92jLybIA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620313; x=1688212313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yLwJ0tgwKXkMFjE8GLsGzdve4xY6BIM2K13yGYNufvU=; b=J7t2CYng8gS5K1ORmBa1tXfHJFa8R6chq/0BjEnLpKZduZMAVhYYNksjSWCDiYZRGc hiFzl8eLutPGjCkDOTN9sMqLcl1GDBWK53NmgASor60lfcTB5CfRMTPRtvz7mtSEE0HB N+u8rwg/YVHoHzJA2z8SGVnelCZCSPt0u1o7rRlJmBhDHkJyEjH4CAfxJYn6c/lZwZdt xrrz/2t9TmFQ16W+elFeJiwMvDyQEyFonfU/e6xmsOlZccDjbcXqhnriJVlF4jPbMkAY qGgmiIksVBQeeBd3prz9oXYZXsPFoE6M0xwXkyWhB9a4rJnr40l0YFpAFWv0VvUILcta xs4w== X-Gm-Message-State: AC+VfDy3HlZiS/7OPpoo2EAS0toaRzFZcd/HWiomnBPX2oHYH8NGo8G8 Q7av6DMWv528iLbRccGqAU8asX/U8uu/1IGJXhQIVdmKg+Rir3ku7RHJX7UFDTswDQRy3DnVmJs tXA8dZjO7T1zBpWQgAc3d+DbRbyo3d5voGu1wbWqpUsrAOgGjBuEryCQdce/LoR+H6A+9pMzoDx c= X-Received: by 2002:a17:906:dac1:b0:973:cb21:8479 with SMTP id xi1-20020a170906dac100b00973cb218479mr4557886ejb.70.1685620313323; Thu, 01 Jun 2023 04:51:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BYuwwWOJV+aQscEPvfyPiLiMVzgQEct88iBX4grd1K2KGQ20uk8dhMMSOkIci4ax66u9u6Q== X-Received: by 2002:a17:906:dac1:b0:973:cb21:8479 with SMTP id xi1-20020a170906dac100b00973cb218479mr4557875ejb.70.1685620313109; Thu, 01 Jun 2023 04:51:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 04/12] bochs: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:37 +0200 Message-Id: <20230601115145.196465-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620549502100002 Content-Type: text/plain; charset="utf-8" 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 --- block/bochs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/bochs.c b/block/bochs.c index 2f5ae52c908d..66e7a58e5e31 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -203,7 +203,8 @@ static void bochs_refresh_limits(BlockDriverState *bs, = Error **errp) bs->bl.request_alignment =3D BDRV_SECTOR_SIZE; /* No sub-sector I/O */ } =20 -static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) +static int64_t coroutine_fn GRAPH_RDLOCK +seek_to_sector(BlockDriverState *bs, int64_t sector_num) { BDRVBochsState *s =3D bs->opaque; uint64_t offset =3D sector_num * 512; @@ -224,8 +225,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int= 64_t sector_num) (s->extent_blocks + s->bitmap_blocks)); =20 /* read in bitmap for current extent */ - ret =3D bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), 1, - &bitmap_entry, 0); + ret =3D bdrv_co_pread(bs->file, bitmap_offset + (extent_offset / 8), 1, + &bitmap_entry, 0); if (ret < 0) { return ret; } --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620519; cv=none; d=zohomail.com; s=zohoarc; b=heliM9lsP4eUhFJ+EFtKLYx6puCx5wve23s49/kdpMpbbGYV6Z5BbyICHdbCy5DDCMpSpa1ltfCqBWWqC4a2oyLhPSQ258/hVwJZ6vkAAOLaSH/A3Llw+FDhu5swsptzvpkrNLUZHNsauQNh2afMwuoi7mrw1/Phj7QTr88q180= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9njw4Wxx0XeRAgmG7XlsOr0DLciSKleqOdESpyjG1rU=; b=Ne9ojdglWQcg6TGVrquNqWfYunPlspjB9RwkH2kxjXw/2aco4EeP0bOjdhOkQw1wczgLBGERNm2+8cQrVwMWxpZfRxInrXbPf2K1mLIviwDmyWvScC5Pr3v2ydD3zG5ZrFr1Pe73UoYDgqdf2sZtvzzsweHL/ZnTuWMT7SRKCfQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620519816791.0797777088927; Thu, 1 Jun 2023 04:55:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqd-0001Hi-2C; Thu, 01 Jun 2023 07:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqX-0000st-9Z for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:01 -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 1q4gqU-0000LU-3s for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:00 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-sr1Het0NPgCFYN33XbvQ_Q-1; Thu, 01 Jun 2023 07:51:56 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96fe843f61eso55370466b.2 for ; Thu, 01 Jun 2023 04:51:56 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id l19-20020a056402345300b00504ecc4fa96sm7043082edc.95.2023.06.01.04.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620317; 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: in-reply-to:in-reply-to:references:references; bh=9njw4Wxx0XeRAgmG7XlsOr0DLciSKleqOdESpyjG1rU=; b=PNcjjBAj7xL/8soQW+qz6yVj6+4BhZGU8zfaS4n07ENYlHY0i6iV5kdZ7H3WKhhKtypZLh ebcyCmq+GAsdEDF+04kTExZyQhh2QjDTC3hsaHDDu2z2K9ffwSR0mGz1EFSBtRqrKl3HeF tLHMPrVNTdAJjy9Aozv0+hcL+dT90Ng= X-MC-Unique: sr1Het0NPgCFYN33XbvQ_Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620315; x=1688212315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9njw4Wxx0XeRAgmG7XlsOr0DLciSKleqOdESpyjG1rU=; b=AlOa9lbP/IAZAm1vPHwlzCxjMNPtGzzjxYt+zmvgSkx2dlbcOaDYWOkuy+AxFIb+U0 oXsZLZ42klb2owhHO8wS0x+VeKlU0m2Uep1gQ3dLs5DsZTv8TLwOqKllYRdTJczNOvQy /i/ZLbUX2mKaYtXYvmaR0xLJ0obKjHV1tYWhSK9nAG8cD9B4pNdQyJmTJprZmf4vyzm5 tUmEyqJ44M4F/kf+ZU8WP08EZKAWaz2DHuw5mjfYaarBrDDj/taJSWetRTsbZeVu90hh VFg3q8iGvt0UMPQBCwCYaclNP8IkuTCg3A8SyG+hXbBk+X4YQ1XjQr1HpDaA1+c3Qrs9 nWFA== X-Gm-Message-State: AC+VfDzvJh/HkC3alSdAtwq+Cuatr7+ID96Sq1oTwDcVBI3gqzIDW9t0 tESr++LdFkWGKWj0ouuDO4BsVPBJrL4Tqh6Q7IjPGvKlkz/pJaVO3ZDUIclEbibe+3m8XZPqIaU KRusHn4CgDdpyB8vjgMY+XXwikaEzP7TH8mSSc/wHQkYU0fsOFCSNOaYDM/rqfZq9dQLYB9rv8v k= X-Received: by 2002:aa7:ccd1:0:b0:514:75c3:269b with SMTP id y17-20020aa7ccd1000000b0051475c3269bmr5159105edt.41.1685620314852; Thu, 01 Jun 2023 04:51:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41w+Nr7HmXymW5WeHUQVtpndmgok1IQVhAqFhS4MOlmP+eb9WuK9cXV3LSmQQb3ghm1TxbrQ== X-Received: by 2002:aa7:ccd1:0:b0:514:75c3:269b with SMTP id y17-20020aa7ccd1000000b0051475c3269bmr5159095edt.41.1685620314650; Thu, 01 Jun 2023 04:51:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 05/12] block: mark another function as coroutine_fns and GRAPH_UNLOCKED Date: Thu, 1 Jun 2023 13:51:38 +0200 Message-Id: <20230601115145.196465-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620521907100007 Content-Type: text/plain; charset="utf-8" Mark functions as coroutine_fn when they are only called by other coroutine= _fns and they can suspend. Because this function operates on a BlockBackend, ma= rk it GRAPH_UNLOCKED. Signed-off-by: Paolo Bonzini --- block.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 113e3d90fd52..98cba7d11a56 100644 --- a/block.c +++ b/block.c @@ -555,8 +555,9 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const= char *filename, * On success, return @blk's actual length. * Otherwise, return -errno. */ -static int64_t create_file_fallback_truncate(BlockBackend *blk, - int64_t minimum_size, Error *= *errp) +static int64_t coroutine_fn GRAPH_UNLOCKED +create_file_fallback_truncate(BlockBackend *blk, int64_t minimum_size, + Error **errp) { Error *local_err =3D NULL; int64_t size; @@ -564,14 +565,14 @@ static int64_t create_file_fallback_truncate(BlockBac= kend *blk, =20 GLOBAL_STATE_CODE(); =20 - ret =3D blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0, - &local_err); + ret =3D blk_co_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0, + &local_err); if (ret < 0 && ret !=3D -ENOTSUP) { error_propagate(errp, local_err); return ret; } =20 - size =3D blk_getlength(blk); + size =3D blk_co_getlength(blk); if (size < 0) { error_free(local_err); error_setg_errno(errp, -size, --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620544; cv=none; d=zohomail.com; s=zohoarc; b=Cmv88HdjHVMWhUTAbLlb09q/QDUhOs/zpurAlE7QfZApubF1rFwEqBLo3xRdDcum8dPtewAPaFoSOm6hol3zEEU1wQjJ9mdlaJbNs5CXvyNSEshyxUin42Ej2A65yBRSzFG9Z5Lt7Dv/O0LQCfJyV1kcEoYU8zegK9UjLtjeo5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s9kOsnTIfr8LoecIGmkq1o/fbSu4HEOyb00hkoyFBiI=; b=EOks/0FsbmA0oAcNmUMucfXzOHJ/smm/MI7LGVn6+6Qbl+Jj4FrbiKs+66iklri1js+6nS9+mNAy0pKBC+4BYhR5aPcZYv9zmu2M3qax42SuUs5KB89yRX2fYFDxrJiESPXv2Qv8wd2ePkApX+16j8cyuEKDfxBoWdvyiNfx9Gg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620544412316.2421790011317; Thu, 1 Jun 2023 04:55:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqd-0001IL-5n; Thu, 01 Jun 2023 07:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqZ-00014D-L3 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqX-0000M0-1m for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:02 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-246-kVlOH6zfNJWXhbE5GmXY3g-1; Thu, 01 Jun 2023 07:51:58 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96f9aa23593so52997466b.1 for ; Thu, 01 Jun 2023 04:51:57 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id jx10-20020a170906ca4a00b00966293c06e9sm10405407ejb.126.2023.06.01.04.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620319; 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: in-reply-to:in-reply-to:references:references; bh=s9kOsnTIfr8LoecIGmkq1o/fbSu4HEOyb00hkoyFBiI=; b=W1P8ve4Z2quHoYPn57adH3eUGB56qxq7bnF/3hVzp9rgEFSB8rMShVloCw3tPHVzSyIxER Y5wFtntExFtGF8L6oJwZtLbOyCSKnifGEuozx/cEPfOLBz1OfrQ+fInfQiqTFbtEfjt98J 7NyQwjYea0+Sqd+xOcexO0i2HFWIrqo= X-MC-Unique: kVlOH6zfNJWXhbE5GmXY3g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620316; x=1688212316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s9kOsnTIfr8LoecIGmkq1o/fbSu4HEOyb00hkoyFBiI=; b=lENSjqHpbXhBievVk5JcYbguhz3YAJO4hdRsOx8gt8iPlvxwAihs8vTPmqUfYqG0+r LMnV/8SAXbTlNYcaEJyP5kK4eGLtQSBCYowgDXfyWZtLwnvC+peDtqzHiTkVAAS4TuvC M7sFGmQY94usX6WCGrMkDzeJrmrVJPiVfujCOt8MWvCWYf3LlF/iVJfJjVRMHUAVRxlM O4Sq7vuJPLwbhs4AYvoggC73fLlKYDFW3Ci0mwJS1JxG9CW5Lw7J/Ly62MmaBhyYd2sG XXaiQnGYGrr3Z3MtN9dZ1Ho0O1HPv8Kzk+37v3FHxzfHBwQ7xBPNtXAzQehyXFf+cxSs afqA== X-Gm-Message-State: AC+VfDwIGiTuv+2AeYWba/oMXEtOworjaqZcCQwh7lrWvy3iU1c3IAQu HvdwQj2sx6F84T9+dPeFhyNKME4+z/llOqCahaqdsuc7+eHMLnt6v0+SRgN1pPaRvV6fqRqukt8 zUw+up6iFy+cx6JeAIGYxwuYshF2C97ATV4nsxMoJpstFfe94K+ryr5xYwVRI+gWbYVehsWovoB o= X-Received: by 2002:a17:907:a426:b0:96f:c988:93b with SMTP id sg38-20020a170907a42600b0096fc988093bmr8487682ejc.35.1685620316436; Thu, 01 Jun 2023 04:51:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4P2xh7UnML4pw2fmW4w4oc8vwIV//SO3pXMkNNQ5danwkusOKFGdBZ/NzRDEsxzy7OUhAZOA== X-Received: by 2002:a17:907:a426:b0:96f:c988:93b with SMTP id sg38-20020a170907a42600b0096fc988093bmr8487672ejc.35.1685620316133; Thu, 01 Jun 2023 04:51:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 06/12] cloop: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:39 +0200 Message-Id: <20230601115145.196465-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620545494100003 Content-Type: text/plain; charset="utf-8" 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 --- block/cloop.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/cloop.c b/block/cloop.c index 1e5a52d6b2dc..835a0fe3da0a 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -212,7 +212,8 @@ static void cloop_refresh_limits(BlockDriverState *bs, = Error **errp) bs->bl.request_alignment =3D BDRV_SECTOR_SIZE; /* No sub-sector I/O */ } =20 -static inline int cloop_read_block(BlockDriverState *bs, int block_num) +static int coroutine_fn GRAPH_RDLOCK +cloop_read_block(BlockDriverState *bs, int block_num) { BDRVCloopState *s =3D bs->opaque; =20 @@ -220,8 +221,8 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) int ret; uint32_t bytes =3D s->offsets[block_num + 1] - s->offsets[block_nu= m]; =20 - ret =3D bdrv_pread(bs->file, s->offsets[block_num], bytes, - s->compressed_block, 0); + ret =3D bdrv_co_pread(bs->file, s->offsets[block_num], bytes, + s->compressed_block, 0); if (ret < 0) { return -1; } @@ -244,7 +245,7 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) return 0; } =20 -static int coroutine_fn +static int coroutine_fn GRAPH_RDLOCK cloop_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620519; cv=none; d=zohomail.com; s=zohoarc; b=ZB4zu43EHKILHxUhgasoePU2Sdm6o5LyVdmZ0zvpZH0LLigcnAw8n+ZRjfwXQi1Q7nfpCbtLbYS7rJRqxeArx8I0PFDj3+MZHY2yJDXKi8DMV+cHB5SMUlP+paKp/G35KpOTKeesbL0chf6I75NwFOQ1pqftFEZDWpLVK4d5mzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+OV1Wjlf5YFldxkwSVEmSX2qCVj1nsZjcStFqGwzolQ=; b=h0lMl+ywaPtJnLoXhYDxVvJfhRZMY9DLg6rDfDB+UiPPdhna8cRFCoVTSF2e8LddrAcvC+XO5hLoDuLPhu3/Ok6vQIlsai6+hgxyGmmrFO9q9LPEDMUv+cHujJKg3/1apbBbyeY45I+N5uiNsd2MjRVukyEbRwKT6RsprC1TCG8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620519821425.06621292003524; Thu, 1 Jun 2023 04:55:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqo-0001Tk-RQ; Thu, 01 Jun 2023 07:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqe-0001L0-Dh for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqb-0000Ns-RA for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:07 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-x03aBadfPEGQPwq_LIOp0A-1; Thu, 01 Jun 2023 07:51:59 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-506beab6a73so693121a12.1 for ; Thu, 01 Jun 2023 04:51:59 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id n15-20020a05640206cf00b004fbdfbb5acesm7071254edy.89.2023.06.01.04.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620325; 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: in-reply-to:in-reply-to:references:references; bh=+OV1Wjlf5YFldxkwSVEmSX2qCVj1nsZjcStFqGwzolQ=; b=BvSZZMtTQ1iZBnHICikeIk8Y7THykGFFAcEvm9MxgzVcWOoV7Oz71zoNknEOR0u7NSWcRu dOevel/ClgyH5UECZHCe3tZZok2o7FcCfo4VgEXDGeXcjhre7SDXVsq+zPLpG/8ZqJaJdq 93LnBG7lXQIbEcqcuod3aoFLa+hno/U= X-MC-Unique: x03aBadfPEGQPwq_LIOp0A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620318; x=1688212318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+OV1Wjlf5YFldxkwSVEmSX2qCVj1nsZjcStFqGwzolQ=; b=LdNeplctlQVyfFwqgv1Fth7utt6SeSeSnU71rwaL40mY5MnujvdVPA20ix8FBOnc+b d2JKlLiayMRV99Be1YOFS+G9lGoIMTikglB+UZs5FJ3fig4n9FyYLMjAHFT46/3OqkwH EV4Q1zxznOE8kkkeWi49p4sVqzyPrLsev3LyWCq3J7TD2g8YN99JLc4iibSfQL//842R qxDcDb5rNb8zMYxvux5HgG3Og86tvg8pl0lluF6rkilS4EMynGB7VnnQ8PJWfeZ5TnMY QERn2n3WTajWV4b9mF6sOyBGFGfXJeWOQbIWuXlkj7qRTusF5ja6a4yXzuc36QhQtpJJ 87tA== X-Gm-Message-State: AC+VfDx6TX9tBnr4vyhjmmpMZRMpTJ70BFWue9WkN9VhytdtBD3f1T7l 8fU6ENH4ByknDjHa3yn8ZJj/RKGWU3iWDmiEBabgKOoPpXxwZ3F4eRNJ1ZB5XanrGe46Oiuk60n TKy+rR5aad8oiJqPu7xEHzSR4Y1+0PxMkF29P0LdOP0E3A5r1Np+/m4jPsAWMZLu5HFJMD8jfNi 8= X-Received: by 2002:aa7:d594:0:b0:514:80d1:2790 with SMTP id r20-20020aa7d594000000b0051480d12790mr5508291edq.35.1685620317927; Thu, 01 Jun 2023 04:51:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5U9q/rOclgfZ4AjrmqK21hiDzbxo/NPkb8peqWRFtyf3E25aGATzyIH0nY4oZm4L/aA600GA== X-Received: by 2002:aa7:d594:0:b0:514:80d1:2790 with SMTP id r20-20020aa7d594000000b0051480d12790mr5508283edq.35.1685620317701; Thu, 01 Jun 2023 04:51:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 07/12] dmg: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:40 +0200 Message-Id: <20230601115145.196465-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620521492100003 Content-Type: text/plain; charset="utf-8" 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 --- block/dmg.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 2769900359f8..06a0244a9c16 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -616,7 +616,8 @@ err: return s->n_chunks; /* error */ } =20 -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 =3D bs->opaque; =20 @@ -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 =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], - s->compressed_chunk, 0); + ret =3D 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 =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], - s->compressed_chunk, 0); + ret =3D 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 =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], - s->compressed_chunk, 0); + ret =3D 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 =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], - s->uncompressed_chunk, 0); + ret =3D 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; } =20 -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) { --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620442; cv=none; d=zohomail.com; s=zohoarc; b=RzWtVJt5Fy+GaYvOZIl7aDcn/ouesADP7vXRmPOGsfLaS++2mHTxeJDwMoNIbuNyVxqiE4uKIt4FyvDBUlqMlHoWSmxot6CHYzIKh1hidzCR6aX6XrfgwXYkiDwQ+3jpeu48EY1jOfNAoZKGAWycX3vIUu87hRQAX7D8zRjRJGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620442; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p505Phhkx6YtNgSh3YBugYQztGZodw4U0C8ss9gsYXA=; b=O8Mdx6C3H6vSYxt9hbEScOwW5Qtv+7AWiHY2OT/zHoaRyS9uDgpxh7OnKAiUCqA5igIqEp+5sOPKITLKCoJ6uOoRodFkG6cjSANadP6Ng47yvsIAmdAaxDzTj9JhYMiRui5cSTe3iQ2gUQSdcxEAwG9OTgp7wNdbVlqxGU6HGCs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620442553117.70646051507674; Thu, 1 Jun 2023 04:54:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqn-0001RM-TE; Thu, 01 Jun 2023 07:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqb-0001C8-2Y for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:05 -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 1q4gqZ-0000Mu-Cr for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:04 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-T-PfM9dwP0Si8680Lbkiyw-1; Thu, 01 Jun 2023 07:52:01 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9737cde2ce8so103222966b.1 for ; Thu, 01 Jun 2023 04:52:01 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id lk15-20020a170906cb0f00b0096f5781205fsm10444397ejb.165.2023.06.01.04.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620322; 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: in-reply-to:in-reply-to:references:references; bh=p505Phhkx6YtNgSh3YBugYQztGZodw4U0C8ss9gsYXA=; b=BWc578JzRKl363Zj8FIOFIwFAVkQzoAGA6E7qayHHVF1ySS8xUmIEaCJact0JQ012rJnKT Rg0oqZWy4TGrPT9JSZ1ttWM9HQ4q5D1Gya71+oBxpY6fm3GaJNF7hRbf3NuZVMI2mqwFXQ TrCX1QZBsAysiryJnP1AGgkPUmInCd8= X-MC-Unique: T-PfM9dwP0Si8680Lbkiyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620320; x=1688212320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p505Phhkx6YtNgSh3YBugYQztGZodw4U0C8ss9gsYXA=; b=bm8ww0erom2xx4z7kk+rbInmWJfgDN0G7CPQmQ5Fcp7AGkl5i4OxX91F0RaLOMuJhx n+e5Jo+qvQNieZrqOp4K5UsBDErvATg+QvewuPS83nBsVunocTpxchwgUIYhrLipcUhY ri2LB/uUujIAw4JNp7ypHoj7l8Ol1olyAO4Nx66fX8Xhpvb3eABMdTz/jnkuF9LjnnAK yx0cRsoZUpXNas6RrKq1X5vwtc+j5TdxlaQPRvO7EoOi7dafC0cnjkesLoKn1CFLMREp pYPfa7l+e53rUEiC4inHrlOf75E/uv8VERC+pnel6b4M0SAJYXDR23bBTNSqRPE+K+8E om3g== X-Gm-Message-State: AC+VfDwG11TS9wV2OLzzT54QR/pEAc1suiss4SEmvxTf3HbsTlstkJbT U3fxk2UQI9zvuNXqy2wk9pTGH9Q+NJ8I/9a/yy0aoXzChSisqCTn41a9l79WRsJrEF6wgp3Q6x+ j+UrQMV6XbJ0gDMhqr02Q+ZkXRjMzJ0ZAqORAdlj1q0xz7gVEmDax5fpqrLOXZGhxJodIvY0NUr M= X-Received: by 2002:a17:907:3f2a:b0:96f:7d0a:5981 with SMTP id hq42-20020a1709073f2a00b0096f7d0a5981mr1361261ejc.36.1685620319901; Thu, 01 Jun 2023 04:51:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/ys4qwIWzcNy2ek7sGMt6Y0WclhJcpIReni+mGiHV5jLBQtFIQohf4eWU9220LuOepZA8uw== X-Received: by 2002:a17:907:3f2a:b0:96f:7d0a:5981 with SMTP id hq42-20020a1709073f2a00b0096f7d0a5981mr1361250ejc.36.1685620319633; Thu, 01 Jun 2023 04:51:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 08/12] vmdk: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:41 +0200 Message-Id: <20230601115145.196465-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620443022100003 Content-Type: text/plain; charset="utf-8" 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 --- block/vmdk.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a864069a5a1f..419868a42ae2 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -339,7 +339,8 @@ out: return ret; } =20 -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) =20 desc =3D g_malloc0(DESC_SIZE); tmp_desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); + ret =3D 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); } =20 - ret =3D bdrv_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc,= 0); =20 out: g_free(desc); @@ -2165,7 +2166,7 @@ vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t o= ffset, int64_t bytes, return ret; } =20 -static int GRAPH_UNLOCKED +static int coroutine_fn GRAPH_UNLOCKED vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool comp= ress, 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; =20 if (flat) { - ret =3D blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0, e= rrp); + ret =3D blk_co_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0= , errp); goto exit; } magic =3D cpu_to_be32(VMDK4_MAGIC); @@ -2228,19 +2229,19 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesiz= e, bool flat, bool compress, header.check_bytes[3] =3D 0xa; =20 /* write all the data */ - ret =3D blk_pwrite(blk, 0, sizeof(magic), &magic, 0); + ret =3D blk_co_pwrite(blk, 0, sizeof(magic), &magic, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); goto exit; } - ret =3D blk_pwrite(blk, sizeof(magic), sizeof(header), &header, 0); + ret =3D blk_co_pwrite(blk, sizeof(magic), sizeof(header), &header, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); goto exit; } =20 - ret =3D blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, - PREALLOC_MODE_OFF, 0, errp); + ret =3D blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, fa= lse, + 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 +=3D gt_size) { gd_buf[i] =3D cpu_to_le32(tmp); } - ret =3D blk_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_S= IZE, - gd_buf_size, gd_buf, 0); + ret =3D blk_co_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTO= R_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 +=3D gt_size) { gd_buf[i] =3D cpu_to_le32(tmp); } - ret =3D blk_pwrite(blk, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SI= ZE, - gd_buf_size, gd_buf, 0); + ret =3D 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); } --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620543; cv=none; d=zohomail.com; s=zohoarc; b=JhSplOqYq79s6r+OklyKzsIZVHLXO4xat84BqGlmOL400/LFXrhaRyH7LdJA2/SSejKeBbcFHs5R9x0rWWo+ZDi9NWjVrQ0Ltk+Yz3DyUNa2W2yJv2kV28/3AwUft8L+wU0ViuUC8m6D+nTCEwfIYHCDzqjU5hc9E8TJwOybkOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620543; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Exraz4pe9MsBvAgBn7XjlVETcy1FbQxMyAH+SRVNttc=; b=Ubrqc7vH+cedk1Cfoa5bjEHQuIZ8SRQfBqbttrVgjafuqnP+vm+BDRP1T9CQWfcYivm1JxBrPb6v8EB+C3RDU/PxhGv2BfzeFOBRnqhPeHVrKjkPwrBANR+b6hMpI5teKgvBUk1DUFxgmAAyfE/4bDocBZ5nqDlb/AJ/ePK7JK4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620543662843.4714107240051; Thu, 1 Jun 2023 04:55:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqu-0001X6-Ih; Thu, 01 Jun 2023 07:52:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqs-0001WH-QC for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqd-0000Nx-2J for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:22 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-JF-Ezf6oPJeoj9wyhJj6VQ-1; Thu, 01 Jun 2023 07:52:03 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a355c9028so47175566b.3 for ; Thu, 01 Jun 2023 04:52:03 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id b8-20020a1709064d4800b00965f31ff894sm10371684ejv.137.2023.06.01.04.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620325; 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: in-reply-to:in-reply-to:references:references; bh=Exraz4pe9MsBvAgBn7XjlVETcy1FbQxMyAH+SRVNttc=; b=Ipnajd8fqkvtc9ijws8GPIMipCrWMu4s4jyYNFim5SM2EsZAFL7Eos3RgEHpcm7fPjue2m 0zjhwGe+1lJL4eK7+wT4ui8SBbZjJveaCwcoHw8h+Pl53tcMxbn/+AnffAdKiVLA8ki5KR jSm446mAIV0dWWpHwB1b2rklJjSvTBw= X-MC-Unique: JF-Ezf6oPJeoj9wyhJj6VQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620321; x=1688212321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Exraz4pe9MsBvAgBn7XjlVETcy1FbQxMyAH+SRVNttc=; b=BfdsguZoRvvzMVskFqcuRebbrFkm9rhWzxiRt/tO2RiKxH/rqYfEBSm/ppYGyaPQnK tb98coA1E5In4NZlAtVQUhjG2Du+MVwbsIyCjmG5s10adef1tK0CAoY5IOBdkxcvx/vn dk6msmFYfjrIYh93f//cuVtTeJxekSfTJNDfGaRCcJ/3EcHi7W2hREaDeY+ZqauraCKe OLs5K2QTFnLIUcls1cKm5lL7MfYoOevUo7Q320+qVJgdxwTeT6TAx1cWhCIdnn4yNd61 6jycrqcNviFVCK+vxpt/IRlQY9lTo2TPV1jUriKTSkeBbzryqevHK3+X/l+TSCeaIO/m nVUA== X-Gm-Message-State: AC+VfDzLR5fD8wWv+SeAphEAL0eboz/rdadRFMdOoAznQmRnV1Prhux4 MO3HRfY3qibk6G9pc2/UJuARMsi2WUV8NP7Pm3Bmp7nHN5auvN/jefcEEh8QFWQDpEOjMMp1+4C a+QLIUfWZF8RV5zyBEU/sueYcETnSj5OpQzymOi86PSFlEQ9DTbbjIm9qUOxKg/Sp6LbqdMNacY 0= X-Received: by 2002:a17:906:fe08:b0:973:d8c4:a4df with SMTP id wy8-20020a170906fe0800b00973d8c4a4dfmr7955669ejb.52.1685620321576; Thu, 01 Jun 2023 04:52:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZMs+1fqnlcNRjTlsbm/McpIyQgX6p3s1Z1+NeTKwDkFWfMO6xra5zUuwcc0TmW/vHVcy2TA== X-Received: by 2002:a17:906:fe08:b0:973:d8c4:a4df with SMTP id wy8-20020a170906fe0800b00973d8c4a4dfmr7955646ejb.52.1685620321301; Thu, 01 Jun 2023 04:52:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 09/12] vhdx: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:42 +0200 Message-Id: <20230601115145.196465-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620545539100005 Content-Type: text/plain; charset="utf-8" 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 --- block/vhdx-log.c | 36 +++++++++++++----------- block/vhdx.c | 73 +++++++++++++++++++++++------------------------- block/vhdx.h | 5 ++-- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 38148f107a97..cf36d2b3a346 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -169,9 +169,10 @@ exit: * It is assumed that 'buffer' is at least 4096*num_sectors large. * * 0 is returned on success, -errno otherwise */ -static int vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *lo= g, - uint32_t *sectors_written, void *buffer, - uint32_t num_sectors) +static int coroutine_fn GRAPH_RDLOCK +vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *log, + uint32_t *sectors_written, void *buffer, + uint32_t num_sectors) { int ret =3D 0; uint64_t offset; @@ -195,8 +196,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, /* full */ break; } - ret =3D bdrv_pwrite(bs->file, offset, VHDX_LOG_SECTOR_SIZE, buffer= _tmp, - 0); + ret =3D bdrv_co_pwrite(bs->file, offset, VHDX_LOG_SECTOR_SIZE, buf= fer_tmp, 0); if (ret < 0) { goto exit; } @@ -853,8 +853,9 @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor= *desc, } =20 =20 -static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s, - void *data, uint32_t length, uint64_t offset) +static int coroutine_fn GRAPH_RDLOCK +vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s, + void *data, uint32_t length, uint64_t offset) { int ret =3D 0; void *buffer =3D NULL; @@ -924,7 +925,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, =20 sectors +=3D partial_sectors; =20 - file_length =3D bdrv_getlength(bs->file->bs); + file_length =3D bdrv_co_getlength(bs->file->bs); if (file_length < 0) { ret =3D file_length; goto exit; @@ -971,8 +972,8 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, =20 if (i =3D=3D 0 && leading_length) { /* partial sector at the front of the buffer */ - ret =3D bdrv_pread(bs->file, file_offset, VHDX_LOG_SECTOR_SIZE, - merged_sector, 0); + ret =3D bdrv_co_pread(bs->file, file_offset, VHDX_LOG_SECTOR_S= IZE, + merged_sector, 0); if (ret < 0) { goto exit; } @@ -981,9 +982,9 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, sector_write =3D merged_sector; } else if (i =3D=3D sectors - 1 && trailing_length) { /* partial sector at the end of the buffer */ - ret =3D bdrv_pread(bs->file, file_offset + trailing_length, - VHDX_LOG_SECTOR_SIZE - trailing_length, - merged_sector + trailing_length, 0); + ret =3D bdrv_co_pread(bs->file, file_offset + trailing_length, + VHDX_LOG_SECTOR_SIZE - trailing_length, + merged_sector + trailing_length, 0); if (ret < 0) { goto exit; } @@ -1036,8 +1037,9 @@ exit: } =20 /* Perform a log write, and then immediately flush the entire log */ -int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, - void *data, uint32_t length, uint64_t offset) +int coroutine_fn GRAPH_RDLOCK +vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, + void *data, uint32_t length, uint64_t offset) { int ret =3D 0; VHDXLogSequence logs =3D { .valid =3D true, @@ -1047,7 +1049,7 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BD= RVVHDXState *s, =20 /* Make sure data written (new and/or changed blocks) is stable * on disk, before creating log entry */ - ret =3D bdrv_flush(bs); + ret =3D bdrv_co_flush(bs); if (ret < 0) { goto exit; } @@ -1059,7 +1061,7 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BD= RVVHDXState *s, logs.log =3D s->log; =20 /* Make sure log is stable on disk */ - ret =3D bdrv_flush(bs); + ret =3D bdrv_co_flush(bs); if (ret < 0) { goto exit; } diff --git a/block/vhdx.c b/block/vhdx.c index 798b6aacf419..45a11255b306 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1250,12 +1250,13 @@ exit: * * Returns the file offset start of the new payload block */ -static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, - uint64_t *new_offset, bool *need_zero) +static int coroutine_fn GRAPH_RDLOCK +vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, + uint64_t *new_offset, bool *need_zero) { int64_t current_len; =20 - current_len =3D bdrv_getlength(bs->file->bs); + current_len =3D bdrv_co_getlength(bs->file->bs); if (current_len < 0) { return current_len; } @@ -1271,16 +1272,16 @@ static int vhdx_allocate_block(BlockDriverState *bs= , BDRVVHDXState *s, if (*need_zero) { int ret; =20 - ret =3D bdrv_truncate(bs->file, *new_offset + s->block_size, false, - PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE, NULL); + ret =3D bdrv_co_truncate(bs->file, *new_offset + s->block_size, fa= lse, + PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE, NUL= L); if (ret !=3D -ENOTSUP) { *need_zero =3D false; return ret; } } =20 - return bdrv_truncate(bs->file, *new_offset + s->block_size, false, - PREALLOC_MODE_OFF, 0, NULL); + return bdrv_co_truncate(bs->file, *new_offset + s->block_size, false, + PREALLOC_MODE_OFF, 0, NULL); } =20 /* @@ -1572,12 +1573,10 @@ exit: * The first 64KB of the Metadata section is reserved for the metadata * header and entries; beyond that, the metadata items themselves reside. */ -static int vhdx_create_new_metadata(BlockBackend *blk, - uint64_t image_size, - uint32_t block_size, - uint32_t sector_size, - uint64_t metadata_offset, - VHDXImageType type) +static int coroutine_fn +vhdx_create_new_metadata(BlockBackend *blk, uint64_t image_size, + uint32_t block_size, uint32_t sector_size, + uint64_t metadata_offset, VHDXImageType type) { int ret =3D 0; uint32_t offset =3D 0; @@ -1668,13 +1667,13 @@ static int vhdx_create_new_metadata(BlockBackend *b= lk, VHDX_META_FLAGS_IS_VIRTUAL_DISK; vhdx_metadata_entry_le_export(&md_table_entry[4]); =20 - ret =3D blk_pwrite(blk, metadata_offset, VHDX_HEADER_BLOCK_SIZE, buffe= r, 0); + ret =3D blk_co_pwrite(blk, metadata_offset, VHDX_HEADER_BLOCK_SIZE, bu= ffer, 0); if (ret < 0) { goto exit; } =20 - ret =3D blk_pwrite(blk, metadata_offset + (64 * KiB), - VHDX_METADATA_ENTRY_BUFFER_SIZE, entry_buffer, 0); + ret =3D blk_co_pwrite(blk, metadata_offset + (64 * KiB), + VHDX_METADATA_ENTRY_BUFFER_SIZE, entry_buffer, 0); if (ret < 0) { goto exit; } @@ -1694,10 +1693,11 @@ exit: * Fixed images: default state of the BAT is fully populated, with * file offsets and state PAYLOAD_BLOCK_FULLY_PRESENT. */ -static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, - uint64_t image_size, VHDXImageType type, - bool use_zero_blocks, uint64_t file_offset, - uint32_t length, Error **errp) +static int coroutine_fn +vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, + uint64_t image_size, VHDXImageType type, + bool use_zero_blocks, uint64_t file_offset, + uint32_t length, Error **errp) { int ret =3D 0; uint64_t data_file_offset; @@ -1718,14 +1718,14 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVV= HDXState *s, if (type =3D=3D VHDX_TYPE_DYNAMIC) { /* All zeroes, so we can just extend the file - the end of the BAT * is the furthest thing we have written yet */ - ret =3D blk_truncate(blk, data_file_offset, false, PREALLOC_MODE_O= FF, - 0, errp); + ret =3D blk_co_truncate(blk, data_file_offset, false, PREALLOC_MOD= E_OFF, + 0, errp); if (ret < 0) { goto exit; } } else if (type =3D=3D VHDX_TYPE_FIXED) { - ret =3D blk_truncate(blk, data_file_offset + image_size, false, - PREALLOC_MODE_OFF, 0, errp); + ret =3D blk_co_truncate(blk, data_file_offset + image_size, false, + PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { goto exit; } @@ -1759,7 +1759,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHD= XState *s, s->bat[sinfo.bat_idx] =3D cpu_to_le64(s->bat[sinfo.bat_idx]); sector_num +=3D s->sectors_per_block; } - ret =3D blk_pwrite(blk, file_offset, length, s->bat, 0); + ret =3D blk_co_pwrite(blk, file_offset, length, s->bat, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write the BAT"); goto exit; @@ -1780,15 +1780,12 @@ exit: * to create the BAT itself, we will also cause the BAT to be * created. */ -static int 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, - VHDXImageType type, - uint64_t *metadata_offset, - Error **errp) +static int coroutine_fn +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, + VHDXImageType type, uint64_t *metadata_offset, + Error **errp) { int ret =3D 0; uint32_t offset =3D 0; @@ -1863,15 +1860,15 @@ static int vhdx_create_new_region_table(BlockBacken= d *blk, } =20 /* Now write out the region headers to disk */ - ret =3D blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, VHDX_HEADER_BLOCK_SI= ZE, - buffer, 0); + ret =3D blk_co_pwrite(blk, VHDX_REGION_TABLE_OFFSET, VHDX_HEADER_BLOCK= _SIZE, + buffer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write first region table"); goto exit; } =20 - ret =3D blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, VHDX_HEADER_BLOCK_S= IZE, - buffer, 0); + ret =3D blk_co_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, VHDX_HEADER_BLOC= K_SIZE, + buffer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write second region table"= ); goto exit; diff --git a/block/vhdx.h b/block/vhdx.h index 0b74924cee98..637516b8f307 100644 --- a/block/vhdx.h +++ b/block/vhdx.h @@ -413,8 +413,9 @@ bool vhdx_checksum_is_valid(uint8_t *buf, size_t size, = int crc_offset); int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed, Error **errp); =20 -int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, - void *data, uint32_t length, uint64_t offset); +int coroutine_fn vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXSt= ate *s, + void *data, uint32_t length, + uint64_t offset); =20 static inline void leguid_to_cpus(MSGUID *guid) { --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620575; cv=none; d=zohomail.com; s=zohoarc; b=ig/e+NjTvms+elBB414ICk4tkxHV/O1WqfA7EMfuxK8krpyGlgZiiiLuVkUMuzX2L3paaZRdKVpn8vpSgOkX7MyPSdz+DIeae9gOUCYpvJBDUeRzy421DUZ7wWUpTdWIK1umAdhWU+z1yZ307pndAAPWprco9KyehwzHPQ421l0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sELu+JuugA7vNUqDSioQgxjZTXapoxCw+nHdKxUIhrc=; b=WnIKpHIJEdyCnidpolSnXsQ0Qa26AZoCj3B0bjCB5at5zg3NczQI7HOzcbm4mEm8MuO4gYB0ewRt+orQw8HKE5hn+xrzzYFzaCTdzdhmBJk7oanrYEbOaOaJc4HaNLdc0qDVcwX1sX5/4jFUKtw5s+jOB65hhNV5Lo/evFWR0+4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620575260701.0372912470772; Thu, 1 Jun 2023 04:56:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqq-0001U1-4j; Thu, 01 Jun 2023 07:52:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqh-0001Nn-3a for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqd-0000O6-9d for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:10 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-Bw1zp3rJPPGlSzZ5WKhC0Q-1; Thu, 01 Jun 2023 07:52:05 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9715654ab36so51596866b.0 for ; Thu, 01 Jun 2023 04:52:05 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id j15-20020a1709062a0f00b0096f8c4b1911sm10545100eje.130.2023.06.01.04.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620326; 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: in-reply-to:in-reply-to:references:references; bh=sELu+JuugA7vNUqDSioQgxjZTXapoxCw+nHdKxUIhrc=; b=TFuHBNcBPYJK2DPy36nsxs6pkalA2xNvDMefmneLHdkjkWdMyc/LDxeQd9pxPVT5/Tleew vNlznGK/zo7LfUuNWwZmkfEyLnUL7jqu0+pWCE9MWojpfgUAuGPburoyegoOphrSculSlX TvxTRezUSPFBWukWqaZ7NslH4/u4B3M= X-MC-Unique: Bw1zp3rJPPGlSzZ5WKhC0Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620324; x=1688212324; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sELu+JuugA7vNUqDSioQgxjZTXapoxCw+nHdKxUIhrc=; b=R1Z6GddiSAWF6+7HB91gDQ96ILzQ0Ce9q4Jb/TuvLY0yHMPxxQwX3YhJlRMnHtqo1p uYvZSr8aCV5XB2O/8iipKTvZQlc8u7sxMkVSBQLd6s9W4dm2xOZ+Z696HsK2WtdUtqh0 V7sSjaL4MzvT2mBhnNWU1JF5k4cwJUWniFBnOf6ZJ988wD+vseVjzQjAc1om+SnAD1tZ VhBZ3+5kk3NlG2PToQwr8ZqX7J8GxcFjYqfqm6CoL6Uyck/LYZiRCOQfJqol4iHEllG6 wYdBjvct2eUd1PQNVzN6dT1+q6AFbi3vUvWRgEMfNE3i02GuCRbyxwQAMgoU4sSVlHK5 QZjw== X-Gm-Message-State: AC+VfDxfAWZqdO5uftQvD42hkMuZNrtVCjQAILnfppAvBE+9dUzFfYdE 5Bo4MtNgmF78CEsgzvTcgbpTV1GSlwUaduGhJZIObpnAtUVAYvV51bpgnz8jDN6wxsY/DuUR/Ok FuhaLecpw+UpBgvggCjiQZgncl3wgI8hCE0nNlLwJik6r1vLMuk4kj4doLmBTQFoSvPJsIyftEr Y= X-Received: by 2002:a17:906:eec8:b0:969:b2e2:4f3b with SMTP id wu8-20020a170906eec800b00969b2e24f3bmr7273888ejb.51.1685620323627; Thu, 01 Jun 2023 04:52:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70rwsjPT0cL1t9owMox70UC+lTMi7P1eDprFIVq+IHxMOY0Dk16/ys7OkcUElcgPHKSIyqBg== X-Received: by 2002:a17:906:eec8:b0:969:b2e2:4f3b with SMTP id wu8-20020a170906eec800b00969b2e24f3bmr7273862ejb.51.1685620323070; Thu, 01 Jun 2023 04:52:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 10/12] qcow2: mark more functions as coroutine_fns and GRAPH_RDLOCK Date: Thu, 1 Jun 2023 13:51:43 +0200 Message-Id: <20230601115145.196465-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620575706100005 Content-Type: text/plain; charset="utf-8" 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 --- block/qcow2-bitmap.c | 26 +++++---- block/qcow2-cluster.c | 12 ++-- block/qcow2-refcount.c | 130 +++++++++++++++++++++-------------------- block/qcow2.c | 2 +- block/qcow2.h | 33 +++++------ 5 files changed, 105 insertions(+), 98 deletions(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index a952fd58d85e..037fa2d4351a 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -283,10 +283,9 @@ static int free_bitmap_clusters(BlockDriverState *bs, = Qcow2BitmapTable *tb) /* load_bitmap_data * @bitmap_table entries must satisfy specification constraints. * @bitmap must be cleared */ -static int load_bitmap_data(BlockDriverState *bs, - const uint64_t *bitmap_table, - uint32_t bitmap_table_size, - BdrvDirtyBitmap *bitmap) +static int coroutine_fn GRAPH_RDLOCK +load_bitmap_data(BlockDriverState *bs, const uint64_t *bitmap_table, + uint32_t bitmap_table_size, BdrvDirtyBitmap *bitmap) { int ret =3D 0; BDRVQcow2State *s =3D bs->opaque; @@ -319,7 +318,7 @@ static int load_bitmap_data(BlockDriverState *bs, * already cleared */ } } else { - ret =3D bdrv_pread(bs->file, data_offset, s->cluster_size, buf= , 0); + ret =3D bdrv_co_pread(bs->file, data_offset, s->cluster_size, = buf, 0); if (ret < 0) { goto finish; } @@ -337,8 +336,9 @@ finish: return ret; } =20 -static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs, - Qcow2Bitmap *bm, Error **errp) +static coroutine_fn GRAPH_RDLOCK +BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs, + Qcow2Bitmap *bm, Error **errp) { int ret; uint64_t *bitmap_table =3D NULL; @@ -649,9 +649,10 @@ fail: return NULL; } =20 -int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *r= es, - void **refcount_table, - int64_t *refcount_table_size) +int coroutine_fn +qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, + int64_t *refcount_table_size) { int ret; BDRVQcow2State *s =3D bs->opaque; @@ -957,8 +958,9 @@ static void set_readonly_helper(gpointer bitmap, gpoint= er value) * If header_updated is not NULL then it is set appropriately regardless of * the return value. */ -bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, - bool *header_updated, Error **e= rrp) +bool coroutine_fn GRAPH_RDLOCK +qcow2_load_dirty_bitmaps(BlockDriverState *bs, + bool *header_updated, Error **errp) { BDRVQcow2State *s =3D bs->opaque; Qcow2BitmapList *bm_list; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 39cda7f907ec..427c96c1d039 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -823,10 +823,9 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, * * Return 0 on success and -errno in error cases */ -int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *b= s, - uint64_t offset, - int compressed_size, - uint64_t *host_offs= et) +int coroutine_fn GRAPH_RDLOCK +qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offse= t, + int compressed_size, uint64_t *host_= offset) { BDRVQcow2State *s =3D bs->opaque; int l2_index, ret; @@ -2014,8 +2013,9 @@ fail: * all clusters in the same L2 slice) and returns the number of zeroed * clusters. */ -static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset, - uint64_t nb_clusters, int flags) +static int coroutine_fn +zero_in_l2_slice(BlockDriverState *bs, uint64_t offset, + uint64_t nb_clusters, int flags) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l2_slice; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4cf91bd95581..de527c3ee496 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1069,7 +1069,7 @@ int64_t coroutine_fn qcow2_alloc_clusters_at(BlockDri= verState *bs, uint64_t offs =20 /* only used to allocate compressed sectors. We try to allocate contiguous sectors. size must be <=3D cluster_size */ -int64_t coroutine_fn qcow2_alloc_bytes(BlockDriverState *bs, int size) +int64_t coroutine_fn GRAPH_RDLOCK qcow2_alloc_bytes(BlockDriverState *bs, = int size) { BDRVQcow2State *s =3D bs->opaque; int64_t offset; @@ -1524,10 +1524,11 @@ static int realloc_refcount_array(BDRVQcow2State *s= , void **array, * * Modifies the number of errors in res. */ -int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res, - void **refcount_table, - int64_t *refcount_table_size, - int64_t offset, int64_t size) +int coroutine_fn GRAPH_RDLOCK +qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, + int64_t *refcount_table_size, + int64_t offset, int64_t size) { BDRVQcow2State *s =3D bs->opaque; uint64_t start, last, cluster_offset, k, refcount; @@ -1538,7 +1539,7 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, Bd= rvCheckResult *res, return 0; } =20 - file_len =3D bdrv_getlength(bs->file->bs); + file_len =3D bdrv_co_getlength(bs->file->bs); if (file_len < 0) { return file_len; } @@ -1600,10 +1601,11 @@ enum { * * On failure in-memory @l2_table may be modified. */ -static int fix_l2_entry_by_zero(BlockDriverState *bs, BdrvCheckResult *res, - uint64_t l2_offset, - uint64_t *l2_table, int l2_index, bool act= ive, - bool *metadata_overlap) +static int coroutine_fn GRAPH_RDLOCK +fix_l2_entry_by_zero(BlockDriverState *bs, BdrvCheckResult *res, + uint64_t l2_offset, uint64_t *l2_table, + int l2_index, bool active, + bool *metadata_overlap) { BDRVQcow2State *s =3D bs->opaque; int ret; @@ -1634,8 +1636,8 @@ static int fix_l2_entry_by_zero(BlockDriverState *bs,= BdrvCheckResult *res, goto fail; } =20 - ret =3D bdrv_pwrite_sync(bs->file, l2e_offset, l2_entry_size(s), - &l2_table[idx], 0); + ret =3D bdrv_co_pwrite_sync(bs->file, l2e_offset, l2_entry_size(s), + &l2_table[idx], 0); if (ret < 0) { fprintf(stderr, "ERROR: Failed to overwrite L2 " "table entry: %s\n", strerror(-ret)); @@ -1659,10 +1661,11 @@ fail: * Returns the number of errors found by the checks or -errno if an intern= al * error occurred. */ -static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, - void **refcount_table, - int64_t *refcount_table_size, int64_t l2_off= set, - int flags, BdrvCheckMode fix, bool active) +static int coroutine_fn GRAPH_RDLOCK +check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, + int64_t *refcount_table_size, int64_t l2_offset, + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; uint64_t l2_entry, l2_bitmap; @@ -1673,7 +1676,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, bool metadata_overlap; =20 /* Read L2 table from disk */ - ret =3D bdrv_pread(bs->file, l2_offset, l2_size_bytes, l2_table, 0); + ret =3D bdrv_co_pread(bs->file, l2_offset, l2_size_bytes, l2_table, 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; @@ -1858,12 +1861,11 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, * Returns the number of errors found by the checks or -errno if an intern= al * error occurred. */ -static int check_refcounts_l1(BlockDriverState *bs, - BdrvCheckResult *res, - void **refcount_table, - int64_t *refcount_table_size, - int64_t l1_table_offset, int l1_size, - int flags, BdrvCheckMode fix, bool active) +static int coroutine_fn GRAPH_RDLOCK +check_refcounts_l1(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, int64_t *refcount_table_size, + int64_t l1_table_offset, int l1_size, + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; size_t l1_size_bytes =3D l1_size * L1E_SIZE; @@ -1889,7 +1891,7 @@ static int check_refcounts_l1(BlockDriverState *bs, } =20 /* Read L1 table entries from disk */ - ret =3D bdrv_pread(bs->file, l1_table_offset, l1_size_bytes, l1_table,= 0); + ret =3D bdrv_co_pread(bs->file, l1_table_offset, l1_size_bytes, l1_tab= le, 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; @@ -1949,8 +1951,8 @@ static int check_refcounts_l1(BlockDriverState *bs, * have been already detected and sufficiently signaled by the calling fun= ction * (qcow2_check_refcounts) by the time this function is called). */ -static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +static int coroutine_fn GRAPH_RDLOCK +check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMo= de fix) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l2_table =3D qemu_blockalign(bs, s->cluster_size); @@ -2005,8 +2007,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } } =20 - ret =3D bdrv_pread(bs->file, l2_offset, s->l2_size * l2_entry_size= (s), - l2_table, 0); + ret =3D bdrv_co_pread(bs->file, l2_offset, s->l2_size * l2_entry_s= ize(s), + l2_table, 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); @@ -2059,8 +2061,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, l2_offset, s->cluster_size, l2_t= able, - 0); + ret =3D bdrv_co_pwrite(bs->file, l2_offset, s->cluster_size, l= 2_table, 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table: %s\n", strerror(-ret)); @@ -2083,9 +2084,10 @@ fail: * Checks consistency of refblocks and accounts for each refblock in * *refcount_table. */ -static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix, bool *rebuild, - void **refcount_table, int64_t *nb_clusters) +static int coroutine_fn GRAPH_RDLOCK +check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix, bool *rebuild, + void **refcount_table, int64_t *nb_clusters) { BDRVQcow2State *s =3D bs->opaque; int64_t i, size; @@ -2127,13 +2129,13 @@ static int check_refblocks(BlockDriverState *bs, Bd= rvCheckResult *res, goto resize_fail; } =20 - ret =3D bdrv_truncate(bs->file, offset + s->cluster_size, = false, - PREALLOC_MODE_OFF, 0, &local_err); + ret =3D bdrv_co_truncate(bs->file, offset + s->cluster_siz= e, false, + PREALLOC_MODE_OFF, 0, &local_err); if (ret < 0) { error_report_err(local_err); goto resize_fail; } - size =3D bdrv_getlength(bs->file->bs); + size =3D bdrv_co_getlength(bs->file->bs); if (size < 0) { ret =3D size; goto resize_fail; @@ -2197,9 +2199,10 @@ resize_fail: /* * Calculates an in-memory refcount table. */ -static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix, bool *rebuild, - void **refcount_table, int64_t *nb_clusters) +static int coroutine_fn GRAPH_RDLOCK +calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix, bool *rebuild, + void **refcount_table, int64_t *nb_clusters) { BDRVQcow2State *s =3D bs->opaque; int64_t i; @@ -2299,10 +2302,11 @@ static int calculate_refcounts(BlockDriverState *bs= , BdrvCheckResult *res, * Compares the actual reference count for each cluster in the image again= st the * refcount as reported by the refcount structures on-disk. */ -static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix, bool *rebuild, - int64_t *highest_cluster, - void *refcount_table, int64_t nb_clusters) +static void coroutine_fn +compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix, bool *rebuild, + int64_t *highest_cluster, + void *refcount_table, int64_t nb_clusters) { BDRVQcow2State *s =3D bs->opaque; int64_t i; @@ -2463,7 +2467,8 @@ static int64_t alloc_clusters_imrt(BlockDriverState *= bs, * Return whether the on-disk reftable array was resized (true/false), * or -errno on error. */ -static int rebuild_refcounts_write_refblocks( +static int coroutine_fn GRAPH_RDLOCK +rebuild_refcounts_write_refblocks( BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters, int64_t first_cluster, int64_t end_cluster, uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entrie= s_ptr, @@ -2578,8 +2583,8 @@ static int rebuild_refcounts_write_refblocks( on_disk_refblock =3D (void *)((char *) *refcount_table + refblock_index * s->cluster_size); =20 - ret =3D bdrv_pwrite(bs->file, refblock_offset, s->cluster_size, - on_disk_refblock, 0); + ret =3D bdrv_co_pwrite(bs->file, refblock_offset, s->cluster_size, + on_disk_refblock, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing refblock"); return ret; @@ -2601,11 +2606,10 @@ static int rebuild_refcounts_write_refblocks( * On success, the old refcount structure is leaked (it will be covered by= the * new refcount structure). */ -static int rebuild_refcount_structure(BlockDriverState *bs, - BdrvCheckResult *res, - void **refcount_table, - int64_t *nb_clusters, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +rebuild_refcount_structure(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, int64_t *nb_clusters, + Error **errp) { BDRVQcow2State *s =3D bs->opaque; int64_t reftable_offset =3D -1; @@ -2734,8 +2738,8 @@ static int rebuild_refcount_structure(BlockDriverStat= e *bs, } =20 assert(reftable_length < INT_MAX); - ret =3D bdrv_pwrite(bs->file, reftable_offset, reftable_length, - on_disk_reftable, 0); + ret =3D bdrv_co_pwrite(bs->file, reftable_offset, reftable_length, + on_disk_reftable, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing reftable"); goto fail; @@ -2745,10 +2749,10 @@ static int rebuild_refcount_structure(BlockDriverSt= ate *bs, reftable_offset_and_clusters.reftable_offset =3D cpu_to_be64(reftable_= offset); reftable_offset_and_clusters.reftable_clusters =3D cpu_to_be32(reftable_clusters); - ret =3D bdrv_pwrite_sync(bs->file, - offsetof(QCowHeader, refcount_table_offset), - sizeof(reftable_offset_and_clusters), - &reftable_offset_and_clusters, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, + offsetof(QCowHeader, refcount_table_offset), + sizeof(reftable_offset_and_clusters), + &reftable_offset_and_clusters, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR setting reftable"); goto fail; @@ -2777,8 +2781,8 @@ fail: * Returns 0 if no errors are found, the number of errors in case the imag= e is * detected as corrupted, and -errno when an internal error occurred. */ -int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +int coroutine_fn GRAPH_RDLOCK +qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvChec= kMode fix) { BDRVQcow2State *s =3D bs->opaque; BdrvCheckResult pre_compare_res; @@ -2787,7 +2791,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvC= heckResult *res, bool rebuild =3D false; int ret; =20 - size =3D bdrv_getlength(bs->file->bs); + size =3D bdrv_co_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; @@ -3541,7 +3545,8 @@ done: return ret; } =20 -static int64_t get_refblock_offset(BlockDriverState *bs, uint64_t offset) +static int64_t coroutine_fn get_refblock_offset(BlockDriverState *bs, + uint64_t offset) { BDRVQcow2State *s =3D bs->opaque; uint32_t index =3D offset_to_reftable_index(s, offset); @@ -3707,7 +3712,8 @@ int64_t coroutine_fn qcow2_get_last_cluster(BlockDriv= erState *bs, int64_t size) return -EIO; } =20 -int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs) +int coroutine_fn GRAPH_RDLOCK +qcow2_detect_metadata_preallocation(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; int64_t i, end_cluster, cluster_count =3D 0, threshold; diff --git a/block/qcow2.c b/block/qcow2.c index ad8250ce35fc..98dcbe472b77 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -570,7 +570,7 @@ int qcow2_mark_corrupt(BlockDriverState *bs) * Marks the image as consistent, i.e., unsets the corrupt bit, and flushes * before if necessary. */ -int qcow2_mark_consistent(BlockDriverState *bs) +static int coroutine_fn qcow2_mark_consistent(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; =20 diff --git a/block/qcow2.h b/block/qcow2.h index 4f67eb912ada..9aedf3348838 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -833,7 +833,6 @@ int64_t qcow2_refcount_metadata_size(int64_t clusters, = size_t cluster_size, =20 int qcow2_mark_dirty(BlockDriverState *bs); int qcow2_mark_corrupt(BlockDriverState *bs); -int qcow2_mark_consistent(BlockDriverState *bs); int qcow2_update_header(BlockDriverState *bs); =20 void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t off= set, @@ -864,7 +863,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t offset, int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size); int64_t coroutine_fn qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_= t offset, int64_t nb_clusters); -int64_t coroutine_fn qcow2_alloc_bytes(BlockDriverState *bs, int size); +int64_t coroutine_fn GRAPH_RDLOCK qcow2_alloc_bytes(BlockDriverState *bs, = int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, enum qcow2_discard_type type); @@ -876,8 +875,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs, =20 int qcow2_flush_caches(BlockDriverState *bs); int qcow2_write_caches(BlockDriverState *bs); -int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix); +int coroutine_fn qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResu= lt *res, + BdrvCheckMode fix); =20 void qcow2_process_discards(BlockDriverState *bs, int ret); =20 @@ -885,10 +884,10 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs= , int ign, int64_t offset, int64_t size); int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t o= ffset, int64_t size, bool data_file); -int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res, - void **refcount_table, - int64_t *refcount_table_size, - int64_t offset, int64_t size); +int coroutine_fn qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckR= esult *res, + void **refcount_table, + int64_t *refcount_table_size, + int64_t offset, int64_t size); =20 int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order, BlockDriverAmendStatusCB *status_cb, @@ -916,10 +915,9 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64= _t offset, int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t of= fset, unsigned int *bytes, uint64_t *host_offset, QCowL2Meta= **m); -int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *b= s, - uint64_t offset, - int compressed_size, - uint64_t *host_offs= et); +int coroutine_fn GRAPH_RDLOCK +qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offse= t, + int compressed_size, uint64_t *host_= offset); void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_ent= ry, uint64_t *coffset, int *csize); =20 @@ -989,11 +987,12 @@ void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint= 64_t offset); void qcow2_cache_discard(Qcow2Cache *c, void *table); =20 /* qcow2-bitmap.c functions */ -int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *r= es, - void **refcount_table, - int64_t *refcount_table_size); -bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, - bool *header_updated, Error **e= rrp); +int coroutine_fn +qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, + void **refcount_table, + int64_t *refcount_table_size); +bool coroutine_fn GRAPH_RDLOCK +qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, Error= **errp); bool qcow2_get_bitmap_info_list(BlockDriverState *bs, Qcow2BitmapInfoList **info_list, Error **e= rrp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620367; cv=none; d=zohomail.com; s=zohoarc; b=lSgx5yZ39jp+1KdsOCw3C/IwFU1HdsmyU4DKUJs8GnXSMrMVSm6HDFITss7P5YSe8TPH/cIopMGgLLHTyvACG0VgG3lZ8QnFrR0NxMzwjE7gGCyf1z5VM9JD2TuC0NfJWpxgcfgjq7GDdX3ZbV/hQ/lk5c3LHDfzZoFF6M/xafs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620367; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=swRLIgFHvUeySROi5KlkYuivHMcmETHAy6qF2wWS6zw=; b=advq9rS6z9s9jo7+d37awJV/b7o/OfUVcWZtP47GpPVlLv28zhvWE5hwf5zsfxUDwfddCm8esSeUSxhLkiftW6Nmnb1Qvg9GD+O5Ci4H5EY4QhPWRqy2LpBh0KuPx1MBQO6CemD8Bvn3xcZrR1/CPlE3IJzVhvpa2BPjYp/x2Y4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620367880656.8251555580324; Thu, 1 Jun 2023 04:52:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqp-0001To-NK; Thu, 01 Jun 2023 07:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqi-0001Oi-IP for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqf-0000OU-9A for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:12 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-nNmgzhnvNN6gzSEjKrpI2Q-1; Thu, 01 Jun 2023 07:52:07 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a34e35f57so52148366b.3 for ; Thu, 01 Jun 2023 04:52:06 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id j23-20020a17090643d700b0095850aef138sm10473906ejn.6.2023.06.01.04.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620328; 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: in-reply-to:in-reply-to:references:references; bh=swRLIgFHvUeySROi5KlkYuivHMcmETHAy6qF2wWS6zw=; b=XglNizX+fEn3s0gaiuQsJeQBv/2fOy+b1VzXZonRMMviOYmSUdtaBCCbnnWcYqoPfHQWG4 O9dEQIvqrBYDiogIeebWvAKX6EA38kQbezE7B9X0SIbUA/wyN34GLSNxJCYqDIDqJUnl6u Ruodt+mReQ1PjEXbgUjEjSA4jbsgSPM= X-MC-Unique: nNmgzhnvNN6gzSEjKrpI2Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620325; x=1688212325; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=swRLIgFHvUeySROi5KlkYuivHMcmETHAy6qF2wWS6zw=; b=aKDXA+gf/RO2swgC0ZZKWhGQQr0ByvBF9pmjUaIu2McHA2WsRxEDbvMOUltVRsqOmH XWEqPx2P0r8xyMuF2k5bLRv/ASjp+fVm9FIKt68WdQQc7NKaG8WEmIMk0yG4lfmFFWgI P/WGv0f8ED+AYpn/vi8UKVLtSICu8n+DlTw+MEo3m2HZXn/9E4SeoQYy6KgabIcbiZrM ggzE4GPItWdCzMDjLPkMT4fX+AJaYH7ZxPzVY9gSt9rq7V+s21p3LBywNKOweZfbgo5t IJFk8UV5bhxgp317WczgaRBn7scNSOmKw1+/Fh6rCmYW36/T1pVS9djqNd9ubmM4T5lp 1YEQ== X-Gm-Message-State: AC+VfDwxmK5MTjS2SoDE8dlS+D+saiL+ebAEOft8owNAnb6rKs3Brk2M Da0CrA5WtORxvZtKFQJivUYsPMoOSr5CdCbutzJ2DVHuZAQzEs8AHaxst/eXRa9VB3cnBgx+Pej x4dcKY7on9jQLH0beMMX330/GIRTNgNmylUEwRKwW3Oa5IO7aLuhqDVAke5nAfsPwuMBtf7wifS w= X-Received: by 2002:a17:907:7d94:b0:973:e184:e0fd with SMTP id oz20-20020a1709077d9400b00973e184e0fdmr7835792ejc.70.1685620325143; Thu, 01 Jun 2023 04:52:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41wcrSGeGkervzkn+/Ykp+mclNstKeKgXfLzExigOohsJJVB3df2KQ9+PWH9ZFz3txLXtxOQ== X-Received: by 2002:a17:907:7d94:b0:973:e184:e0fd with SMTP id oz20-20020a1709077d9400b00973e184e0fdmr7835772ejc.70.1685620324835; Thu, 01 Jun 2023 04:52:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 11/12] block: use bdrv_co_getlength in coroutine context Date: Thu, 1 Jun 2023 13:51:44 +0200 Message-Id: <20230601115145.196465-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620368329100003 Content-Type: text/plain; charset="utf-8" bdrv_co_getlength was recently introduced, with bdrv_getlength becoming a wrapper for use in unknown context. Switch to bdrv_co_getlength when possible. Signed-off-by: Paolo Bonzini --- block/io.c | 10 +++++----- block/parallels.c | 4 ++-- block/qcow.c | 6 +++--- block/vmdk.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/block/io.c b/block/io.c index 3bd4c7de97f0..f537421ef523 100644 --- a/block/io.c +++ b/block/io.c @@ -1379,7 +1379,7 @@ bdrv_aligned_preadv(BdrvChild *child, BdrvTrackedRequ= est *req, } =20 /* Forward the request to the BlockDriver, possibly fragmenting it */ - total_bytes =3D bdrv_getlength(bs); + total_bytes =3D bdrv_co_getlength(bs); if (total_bytes < 0) { ret =3D total_bytes; goto out; @@ -2252,7 +2252,7 @@ bdrv_co_do_block_status(BlockDriverState *bs, bool wa= nt_zero, assert(pnum); assert_bdrv_graph_readable(); *pnum =3D 0; - total_size =3D bdrv_getlength(bs); + total_size =3D bdrv_co_getlength(bs); if (total_size < 0) { ret =3D total_size; goto early_out; @@ -2272,7 +2272,7 @@ bdrv_co_do_block_status(BlockDriverState *bs, bool wa= nt_zero, bytes =3D n; } =20 - /* Must be non-NULL or bdrv_getlength() would have failed */ + /* Must be non-NULL or bdrv_co_getlength() would have failed */ assert(bs->drv); has_filtered_child =3D bdrv_filter_child(bs); if (!bs->drv->bdrv_co_block_status && !has_filtered_child) { @@ -2410,7 +2410,7 @@ bdrv_co_do_block_status(BlockDriverState *bs, bool wa= nt_zero, if (!cow_bs) { ret |=3D BDRV_BLOCK_ZERO; } else if (want_zero) { - int64_t size2 =3D bdrv_getlength(cow_bs); + int64_t size2 =3D bdrv_co_getlength(cow_bs); =20 if (size2 >=3D 0 && offset >=3D size2) { ret |=3D BDRV_BLOCK_ZERO; @@ -3445,7 +3445,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, return ret; } =20 - old_size =3D bdrv_getlength(bs); + old_size =3D bdrv_co_getlength(bs); if (old_size < 0) { error_setg_errno(errp, -old_size, "Failed to get old image size"); return old_size; diff --git a/block/parallels.c b/block/parallels.c index 190406ba2e3d..91247cb157f6 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -193,7 +193,7 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_= num, assert(idx < s->bat_size && idx + to_allocate <=3D s->bat_size); =20 space =3D to_allocate * s->tracks; - len =3D bdrv_getlength(bs->file->bs); + len =3D bdrv_co_getlength(bs->file->bs); if (len < 0) { return len; } @@ -426,7 +426,7 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResul= t *res, uint32_t i; bool flush_bat =3D false; =20 - size =3D bdrv_getlength(bs->file->bs); + size =3D bdrv_co_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; diff --git a/block/qcow.c b/block/qcow.c index 823e931cea2d..4aee835e8c36 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -370,7 +370,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, if (!allocate) return 0; /* allocate a new l2 entry */ - l2_offset =3D bdrv_getlength(bs->file->bs); + l2_offset =3D bdrv_co_getlength(bs->file->bs); if (l2_offset < 0) { return l2_offset; } @@ -445,7 +445,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, if (decompress_cluster(bs, cluster_offset) < 0) { return -EIO; } - cluster_offset =3D bdrv_getlength(bs->file->bs); + cluster_offset =3D bdrv_co_getlength(bs->file->bs); if ((int64_t) cluster_offset < 0) { return cluster_offset; } @@ -458,7 +458,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, return ret; } } else { - cluster_offset =3D bdrv_getlength(bs->file->bs); + cluster_offset =3D bdrv_co_getlength(bs->file->bs); if ((int64_t) cluster_offset < 0) { return cluster_offset; } diff --git a/block/vmdk.c b/block/vmdk.c index 419868a42ae2..c64f2eacc03f 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2132,7 +2132,7 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int6= 4_t offset, int64_t bytes, int64_t length; =20 for (i =3D 0; i < s->num_extents; i++) { - length =3D bdrv_getlength(s->extents[i].file->bs); + length =3D bdrv_co_getlength(s->extents[i].file->bs); if (length < 0) { return length; } @@ -2939,7 +2939,7 @@ vmdk_co_check(BlockDriverState *bs, BdrvCheckResult *= result, BdrvCheckMode fix) break; } if (ret =3D=3D VMDK_OK) { - int64_t extent_len =3D bdrv_getlength(extent->file->bs); + int64_t extent_len =3D bdrv_co_getlength(extent->file->bs); if (extent_len < 0) { fprintf(stderr, "ERROR: could not get extent file length for secto= r %" --=20 2.40.1 From nobody Sun Apr 28 16:04:08 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685620577; cv=none; d=zohomail.com; s=zohoarc; b=X82xFu/tQ3shmwlmKJHMJR0jTcFyLG7mhhgFvYJOaTuOmZB9HpLMjhqgXIXzgWVXYrT1qmt+zYfp8IS01yXg3BZauvPuKoDprGcHDUjYZHXwcwz3pjr1FVK+hB1d+xqQjPcQQD5nPv1Ad2gBPaCO01B7ZAj3C0EaHicbafS+5Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685620577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NJZxX/GSw0FE7vhnB8bRKXEkHq0sonSPw98sySoYJqU=; b=m0/f5fau0SQIx6K/0VS42sWpydxB0u26qzFLtAbogMGPynHdimJJoRkG+fi9aGsGqGbLGtP/fMOsssrFiHEr4y1QMNEKFrgmD1+MXlA4mRdmq995TfaDHIuugv0dfEapUbKTZE1bGzQNouuj573+gMX/p4RCMod46HWpJQR7nr4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685620577953283.1349452855758; Thu, 1 Jun 2023 04:56:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gqq-0001U6-BV; Thu, 01 Jun 2023 07:52:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4gqk-0001Qy-Su for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:15 -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 1q4gqh-0000Oh-0l for qemu-devel@nongnu.org; Thu, 01 Jun 2023 07:52:14 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-oExuQOm2NTevHOs-OeKvnQ-1; Thu, 01 Jun 2023 07:52:09 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-96f9996fb3dso48739366b.2 for ; Thu, 01 Jun 2023 04:52:08 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id dv22-20020a170906b81600b0096f78953b77sm10516410ejb.147.2023.06.01.04.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 04:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685620330; 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: in-reply-to:in-reply-to:references:references; bh=NJZxX/GSw0FE7vhnB8bRKXEkHq0sonSPw98sySoYJqU=; b=A/7ZOn3JoDu1hL3AD9AbgB9g6ovFAFt+RBhmtzqxMxwqWCAZgYZWomO2/er2j1dRWVFufo pBalpVPXymnJPHJhwl/J5a7llRavxQBuT7TjK3Oc4bRXQ+zlg3PspU6Ht4cXLYOyLWincX MpqyMcWavfR4GhLu8sgmeOGcxcSOxLA= X-MC-Unique: oExuQOm2NTevHOs-OeKvnQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685620327; x=1688212327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NJZxX/GSw0FE7vhnB8bRKXEkHq0sonSPw98sySoYJqU=; b=Wfvcr1K1lPu0VmZ7GSmp6sCllbR3t/aN+ty5q7gbVi9NzCLCPz86JZHtNyYvwER24K IQLvM3l8Q6Jxw8/qaRI4BgSajqQ4CYPoMvqAhscBLjE8ha0vypEX1KOrC+dw3ACzoxWJ 7y/IVIW3qI4xYz2+zXTE8chQg4PSRmOuFMx43Y2Kj1qNToReWW0i3yPW4HhRTny6+rmJ Jz1Fn5U1EqfIE/2l/w6f0m815FrMXXPPtSLKSN43pZyKi6IUdofndDJNqRQ2bd53nW84 xg8nTTO7ZJmlTtFni2p91Zo7PL5Aqyicm0ZKaG5iKrI/5UP4yEcOehzLj65ks3eqDq+s MuVQ== X-Gm-Message-State: AC+VfDzVSzOG71TDCsK5+C/jKCixGC9iLE1gCUKE2kVG37Br6KRKUNt6 2ox5CeGloJO5hQdi/SrlJaph/2iuGeTZ+QDPCLFqIHPuA6zgLaldVW14AtNg0RhoOBr6S3p3ssu 6/oJSCsJxzu5ys+sxCCy/7a5kDZ/mIDap7XbpPR5nBiXd9zyMdLJf0TU6QSNJDPORxag7IdGxfw g= X-Received: by 2002:a17:907:7da6:b0:96a:1cbf:3dcc with SMTP id oz38-20020a1709077da600b0096a1cbf3dccmr9131817ejc.54.1685620327313; Thu, 01 Jun 2023 04:52:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5JYaz68Hu5D+3nKov5IaVYyLCToRLKSJEn/tUqpy09IiPqv+XNnJuarVlBkuFXf7G3W7Fpng== X-Received: by 2002:a17:907:7da6:b0:96a:1cbf:3dcc with SMTP id oz38-20020a1709077da600b0096a1cbf3dccmr9131796ejc.54.1685620326890; Thu, 01 Jun 2023 04:52:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: [PATCH 12/12] block: use bdrv_co_debug_event in coroutine context Date: Thu, 1 Jun 2023 13:51:45 +0200 Message-Id: <20230601115145.196465-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601115145.196465-1-pbonzini@redhat.com> References: <20230601115145.196465-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1685620580141100003 Content-Type: text/plain; charset="utf-8" bdrv_co_debug_event was recently introduced, with bdrv_debug_event becoming a wrapper for use in unknown context. Because most of the time bdrv_debug_event is used on a BdrvChild via the wrapper macro BLKDBG_EVENT, introduce a similar macro BLKDBG_CO_EVENT that calls bdrv_co_debug_event, and switch whenever possible. Signed-off-by: Paolo Bonzini --- block/io.c | 4 ++-- block/qcow.c | 24 ++++++++++++------------ block/qcow2-cluster.c | 12 ++++++------ block/qcow2-refcount.c | 4 ++-- block/qcow2.c | 18 +++++++++--------- block/qed-table.c | 6 +++--- block/qed.c | 8 ++++---- block/raw-format.c | 4 ++-- block/vmdk.c | 24 ++++++++++++------------ include/block/block-io.h | 7 +++++++ 10 files changed, 59 insertions(+), 52 deletions(-) diff --git a/block/io.c b/block/io.c index f537421ef523..e48b7454cfd8 100644 --- a/block/io.c +++ b/block/io.c @@ -2827,7 +2827,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) } =20 /* Write back cached data to the OS even with cache=3Dunsafe */ - BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_OS); + BLKDBG_CO_EVENT(primary_child, BLKDBG_FLUSH_TO_OS); if (bs->drv->bdrv_co_flush_to_os) { ret =3D bs->drv->bdrv_co_flush_to_os(bs); if (ret < 0) { @@ -2845,7 +2845,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) goto flush_children; } =20 - BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_DISK); + BLKDBG_CO_EVENT(primary_child, BLKDBG_FLUSH_TO_DISK); if (!bs->drv) { /* bs->drv->bdrv_co_flush() might have ejected the BDS * (even in case of apparent success) */ diff --git a/block/qcow.c b/block/qcow.c index 4aee835e8c36..94aba110fd32 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -379,7 +379,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, /* update the L1 entry */ s->l1_table[l1_index] =3D l2_offset; tmp =3D cpu_to_be64(l2_offset); - BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_UPDATE); ret =3D bdrv_co_pwrite_sync(bs->file, s->l1_table_offset + l1_index * sizeof(t= mp), sizeof(tmp), &tmp, 0); @@ -410,7 +410,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, } } l2_table =3D s->l2_cache + (min_index << s->l2_bits); - BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_LOAD); if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); ret =3D bdrv_co_pwrite_sync(bs->file, l2_offset, @@ -434,7 +434,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate =3D=3D 1)) { if (!allocate) return 0; - BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC); + BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC); assert(QEMU_IS_ALIGNED(n_start | n_end, BDRV_SECTOR_SIZE)); /* allocate a new cluster */ if ((cluster_offset & QCOW_OFLAG_COMPRESSED) && @@ -451,7 +451,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, } cluster_offset =3D QEMU_ALIGN_UP(cluster_offset, s->cluster_si= ze); /* write the cluster content */ - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_co_pwrite(bs->file, cluster_offset, s->cluster_si= ze, s->cluster_cache, 0); if (ret < 0) { @@ -491,7 +491,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, NULL) < 0) { return -EIO; } - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_co_pwrite(bs->file, cluster_offse= t + i, BDRV_SECTOR_SIZE, s->cluster_data, 0); @@ -510,9 +510,9 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offse= t, int allocate, tmp =3D cpu_to_be64(cluster_offset); l2_table[l2_index] =3D tmp; if (allocate =3D=3D 2) { - BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); } else { - BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE); } ret =3D bdrv_co_pwrite_sync(bs->file, l2_offset + l2_index * sizeo= f(tmp), sizeof(tmp), &tmp, 0); @@ -595,7 +595,7 @@ decompress_cluster(BlockDriverState *bs, uint64_t clust= er_offset) if (s->cluster_cache_offset !=3D coffset) { csize =3D cluster_offset >> (63 - s->cluster_bits); csize &=3D (s->cluster_size - 1); - BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_COMPRESSED); ret =3D bdrv_co_pread(bs->file, coffset, csize, s->cluster_data, 0= ); if (ret < 0) return -1; @@ -657,7 +657,7 @@ qcow_co_preadv(BlockDriverState *bs, int64_t offset, in= t64_t bytes, /* read from the base image */ qemu_co_mutex_unlock(&s->lock); /* qcow2 emits this on bs->file instead of bs->backing */ - BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); ret =3D bdrv_co_pread(bs->backing, offset, n, buf, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { @@ -680,7 +680,7 @@ qcow_co_preadv(BlockDriverState *bs, int64_t offset, in= t64_t bytes, break; } qemu_co_mutex_unlock(&s->lock); - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); ret =3D bdrv_co_pread(bs->file, cluster_offset + offset_in_clu= ster, n, buf, 0); qemu_co_mutex_lock(&s->lock); @@ -765,7 +765,7 @@ qcow_co_pwritev(BlockDriverState *bs, int64_t offset, i= nt64_t bytes, } =20 qemu_co_mutex_unlock(&s->lock); - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_co_pwrite(bs->file, cluster_offset + offset_in_cluste= r, n, buf, 0); qemu_co_mutex_lock(&s->lock); @@ -1114,7 +1114,7 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, int6= 4_t offset, int64_t bytes, } cluster_offset &=3D s->cluster_offset_mask; =20 - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); ret =3D bdrv_co_pwrite(bs->file, cluster_offset, out_len, out_buf, 0); if (ret < 0) { goto fail; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 427c96c1d039..8ba8722a19cf 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -48,7 +48,7 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *= bs, fprintf(stderr, "shrink l1_table from %d to %d\n", s->l1_size, new_l1_= size); #endif =20 - BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE); ret =3D bdrv_co_pwrite_zeroes(bs->file, s->l1_table_offset + new_l1_size * L1E_SIZ= E, (s->l1_size - new_l1_size) * L1E_SIZE, 0); @@ -61,7 +61,7 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *= bs, goto fail; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_FREE_L2_CLUSTERS); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_SHRINK_FREE_L2_CLUSTERS); for (i =3D s->l1_size - 1; i > new_l1_size - 1; i--) { if ((s->l1_table[i] & L1E_OFFSET_MASK) =3D=3D 0) { continue; @@ -501,7 +501,7 @@ do_perform_cow_read(BlockDriverState *bs, uint64_t src_= cluster_offset, return 0; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_COW_READ); + BLKDBG_CO_EVENT(bs->file, BLKDBG_COW_READ); =20 if (!bs->drv) { return -ENOMEDIUM; @@ -551,7 +551,7 @@ do_perform_cow_write(BlockDriverState *bs, uint64_t clu= ster_offset, return ret; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_COW_WRITE); ret =3D bdrv_co_pwritev(s->data_file, cluster_offset + offset_in_clust= er, qiov->size, qiov, 0); if (ret < 0) { @@ -871,7 +871,7 @@ qcow2_alloc_compressed_cluster_offset(BlockDriverState = *bs, uint64_t offset, =20 /* compressed clusters never have the copied flag */ =20 - BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); + BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); set_l2_entry(s, l2_slice, l2_index, cluster_offset); if (has_subclusters(s)) { @@ -991,7 +991,7 @@ perform_cow(BlockDriverState *bs, QCowL2Meta *m) /* NOTE: we have a write_aio blkdebug event here followed by * a cow_write one in do_perform_cow_write(), but there's only * one single I/O operation */ - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D do_perform_cow_write(bs, m->alloc_offset, start->offset, &= qiov); } else { /* If there's no guest data then write both COW regions separately= */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index de527c3ee496..5095e99a378e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -118,7 +118,7 @@ int coroutine_fn qcow2_refcount_init(BlockDriverState *= bs) ret =3D -ENOMEM; goto fail; } - BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); + BLKDBG_CO_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); ret =3D bdrv_co_pread(bs->file, s->refcount_table_offset, refcount_table_size2, s->refcount_table, 0); if (ret < 0) { @@ -1076,7 +1076,7 @@ int64_t coroutine_fn GRAPH_RDLOCK qcow2_alloc_bytes(B= lockDriverState *bs, int si size_t free_in_cluster; int ret; =20 - BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES); + BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES); assert(size > 0 && size <=3D s->cluster_size); assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_off= set)); =20 diff --git a/block/qcow2.c b/block/qcow2.c index 98dcbe472b77..fe8ed866cdbc 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2207,7 +2207,7 @@ qcow2_co_preadv_encrypted(BlockDriverState *bs, return -ENOMEM; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); ret =3D bdrv_co_pread(s->data_file, host_offset, bytes, buf, 0); if (ret < 0) { goto fail; @@ -2297,7 +2297,7 @@ qcow2_co_preadv_task(BlockDriverState *bs, QCow2Subcl= usterType subc_type, case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC: assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part = */ =20 - BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); return bdrv_co_preadv_part(bs->backing, offset, bytes, qiov, qiov_offset, 0); =20 @@ -2311,7 +2311,7 @@ qcow2_co_preadv_task(BlockDriverState *bs, QCow2Subcl= usterType subc_type, offset, bytes, qiov, qiov_off= set); } =20 - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); return bdrv_co_preadv_part(s->data_file, host_offset, bytes, qiov, qiov_offset, 0); =20 @@ -2521,7 +2521,7 @@ handle_alloc_space(BlockDriverState *bs, QCowL2Meta *= l2meta) return ret; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_SPACE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_SPACE); ret =3D bdrv_co_pwrite_zeroes(s->data_file, start_offset, nb_bytes, BDRV_REQ_NO_FALLBACK); if (ret < 0) { @@ -2586,7 +2586,7 @@ int qcow2_co_pwritev_task(BlockDriverState *bs, uint6= 4_t host_offset, * guest data now. */ if (!merge_cow(offset, bytes, qiov, qiov_offset, l2meta)) { - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), host_offset); ret =3D bdrv_co_pwritev_part(s->data_file, host_offset, bytes, qiov, qiov_offset, 0); @@ -4661,7 +4661,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, goto fail; } =20 - BLKDBG_EVENT(s->data_file, BLKDBG_WRITE_COMPRESSED); + BLKDBG_CO_EVENT(s->data_file, BLKDBG_WRITE_COMPRESSED); ret =3D bdrv_co_pwrite(s->data_file, cluster_offset, out_len, out_buf,= 0); if (ret < 0) { goto fail; @@ -4780,7 +4780,7 @@ qcow2_co_preadv_compressed(BlockDriverState *bs, =20 out_buf =3D qemu_blockalign(bs, s->cluster_size); =20 - BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_COMPRESSED); ret =3D bdrv_co_pread(bs->file, coffset, csize, buf, 0); if (ret < 0) { goto fail; @@ -5327,7 +5327,7 @@ qcow2_co_save_vmstate(BlockDriverState *bs, QEMUIOVec= tor *qiov, int64_t pos) return offset; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); + BLKDBG_CO_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, = 0); } =20 @@ -5339,7 +5339,7 @@ qcow2_co_load_vmstate(BlockDriverState *bs, QEMUIOVec= tor *qiov, int64_t pos) return offset; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); + BLKDBG_CO_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0= ); } =20 diff --git a/block/qed-table.c b/block/qed-table.c index 3b331ce70986..f04520d4c834 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -122,7 +122,7 @@ int coroutine_fn qed_read_l1_table_sync(BDRVQEDState *s) int coroutine_fn qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int n) { - BLKDBG_EVENT(s->bs->file, BLKDBG_L1_UPDATE); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L1_UPDATE); return qed_write_table(s, s->header.l1_table_offset, s->l1_table, index, n, false); } @@ -150,7 +150,7 @@ int coroutine_fn qed_read_l2_table(BDRVQEDState *s, QED= Request *request, request->l2_table =3D qed_alloc_l2_cache_entry(&s->l2_cache); request->l2_table->table =3D qed_alloc_table(s); =20 - BLKDBG_EVENT(s->bs->file, BLKDBG_L2_LOAD); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L2_LOAD); ret =3D qed_read_table(s, offset, request->l2_table->table); =20 if (ret) { @@ -183,7 +183,7 @@ int coroutine_fn qed_write_l2_table(BDRVQEDState *s, QE= DRequest *request, unsigned int index, unsigned int n, bool flush) { - BLKDBG_EVENT(s->bs->file, BLKDBG_L2_UPDATE); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L2_UPDATE); return qed_write_table(s, request->l2_table->offset, request->l2_table->table, index, n, flush); } diff --git a/block/qed.c b/block/qed.c index 382c05c83fef..5fdbcb0de7b0 100644 --- a/block/qed.c +++ b/block/qed.c @@ -883,7 +883,7 @@ static int coroutine_fn GRAPH_RDLOCK qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov) { if (s->bs->backing) { - BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); return bdrv_co_preadv(s->bs->backing, pos, qiov->size, qiov, 0); } qemu_iovec_memset(qiov, 0, 0, qiov->size); @@ -918,7 +918,7 @@ qed_copy_from_backing_file(BDRVQEDState *s, uint64_t po= s, uint64_t len, goto out; } =20 - BLKDBG_EVENT(s->bs->file, BLKDBG_COW_WRITE); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_COW_WRITE); ret =3D bdrv_co_pwritev(s->bs->file, offset, qiov.size, &qiov, 0); if (ret < 0) { goto out; @@ -1070,7 +1070,7 @@ static int coroutine_fn GRAPH_RDLOCK qed_aio_write_ma= in(QEDAIOCB *acb) =20 trace_qed_aio_write_main(s, acb, 0, offset, acb->cur_qiov.size); =20 - BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(s->bs->file, BLKDBG_WRITE_AIO); return bdrv_co_pwritev(s->bs->file, offset, acb->cur_qiov.size, &acb->cur_qiov, 0); } @@ -1324,7 +1324,7 @@ qed_aio_read_data(void *opaque, int ret, uint64_t off= set, size_t len) } else if (ret !=3D QED_CLUSTER_FOUND) { r =3D qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov); } else { - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); r =3D bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size, &acb->cur_qiov, 0); } diff --git a/block/raw-format.c b/block/raw-format.c index e4f35268e6f3..a8bdee5279ad 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -214,7 +214,7 @@ raw_co_preadv(BlockDriverState *bs, int64_t offset, int= 64_t bytes, return ret; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } =20 @@ -268,7 +268,7 @@ raw_co_pwritev(BlockDriverState *bs, int64_t offset, in= t64_t bytes, goto fail; } =20 - BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); =20 fail: diff --git a/block/vmdk.c b/block/vmdk.c index c64f2eacc03f..82d8f5efe961 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1438,7 +1438,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *e= xtent, if (skip_start_bytes > 0) { if (copy_from_backing) { /* qcow2 emits this on bs->file instead of bs->backing */ - BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); + BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_READ); ret =3D bdrv_co_pread(bs->backing, offset, skip_start_bytes, whole_grain, 0); if (ret < 0) { @@ -1446,7 +1446,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *e= xtent, goto exit; } } - BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); + BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_WRITE); ret =3D bdrv_co_pwrite(extent->file, cluster_offset, skip_start_by= tes, whole_grain, 0); if (ret < 0) { @@ -1458,7 +1458,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *e= xtent, if (skip_end_bytes < cluster_bytes) { if (copy_from_backing) { /* qcow2 emits this on bs->file instead of bs->backing */ - BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); + BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_READ); ret =3D bdrv_co_pread(bs->backing, offset + skip_end_bytes, cluster_bytes - skip_end_bytes, whole_grain + skip_end_bytes, 0); @@ -1467,7 +1467,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *e= xtent, goto exit; } } - BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); + BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_WRITE); ret =3D bdrv_co_pwrite(extent->file, cluster_offset + skip_end_byt= es, cluster_bytes - skip_end_bytes, whole_grain + skip_end_bytes, 0); @@ -1488,7 +1488,7 @@ vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_dat= a, uint32_t offset) { offset =3D cpu_to_le32(offset); /* update L2 table */ - BLKDBG_EVENT(extent->file, BLKDBG_L2_UPDATE); + BLKDBG_CO_EVENT(extent->file, BLKDBG_L2_UPDATE); if (bdrv_co_pwrite(extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), @@ -1618,7 +1618,7 @@ get_cluster_offset(BlockDriverState *bs, VmdkExtent *= extent, } } l2_table =3D (char *)extent->l2_cache + (min_index * l2_size_bytes); - BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); + BLKDBG_CO_EVENT(extent->file, BLKDBG_L2_LOAD); if (bdrv_co_pread(extent->file, (int64_t)l2_offset * 512, l2_size_bytes, @@ -1829,12 +1829,12 @@ vmdk_write_extent(VmdkExtent *extent, int64_t clust= er_offset, n_bytes =3D buf_len + sizeof(VmdkGrainMarker); qemu_iovec_init_buf(&local_qiov, data, n_bytes); =20 - BLKDBG_EVENT(extent->file, BLKDBG_WRITE_COMPRESSED); + BLKDBG_CO_EVENT(extent->file, BLKDBG_WRITE_COMPRESSED); } else { qemu_iovec_init(&local_qiov, qiov->niov); qemu_iovec_concat(&local_qiov, qiov, qiov_offset, n_bytes); =20 - BLKDBG_EVENT(extent->file, BLKDBG_WRITE_AIO); + BLKDBG_CO_EVENT(extent->file, BLKDBG_WRITE_AIO); } =20 write_offset =3D cluster_offset + offset_in_cluster; @@ -1876,7 +1876,7 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_= offset, =20 =20 if (!extent->compressed) { - BLKDBG_EVENT(extent->file, BLKDBG_READ_AIO); + BLKDBG_CO_EVENT(extent->file, BLKDBG_READ_AIO); ret =3D bdrv_co_preadv(extent->file, cluster_offset + offset_in_cluster, bytes, qiov, 0); @@ -1890,7 +1890,7 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_= offset, buf_bytes =3D cluster_bytes * 2; cluster_buf =3D g_malloc(buf_bytes); uncomp_buf =3D g_malloc(cluster_bytes); - BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED); + BLKDBG_CO_EVENT(extent->file, BLKDBG_READ_COMPRESSED); ret =3D bdrv_co_pread(extent->file, cluster_offset, buf_bytes, cluster= _buf, 0); if (ret < 0) { @@ -1968,7 +1968,7 @@ vmdk_co_preadv(BlockDriverState *bs, int64_t offset, = int64_t bytes, qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); =20 /* qcow2 emits this on bs->file instead of bs->backing */ - BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); + BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); ret =3D bdrv_co_preadv(bs->backing, offset, n_bytes, &local_qiov, 0); if (ret < 0) { @@ -2909,7 +2909,7 @@ vmdk_co_check(BlockDriverState *bs, BdrvCheckResult *= result, BdrvCheckMode fix) BDRVVmdkState *s =3D bs->opaque; VmdkExtent *extent =3D NULL; int64_t sector_num =3D 0; - int64_t total_sectors =3D bdrv_nb_sectors(bs); + int64_t total_sectors =3D bdrv_co_nb_sectors(bs); int ret; uint64_t cluster_offset; =20 diff --git a/include/block/block-io.h b/include/block/block-io.h index 3946bbefc5c2..331a549b79b5 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -232,6 +232,13 @@ bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEven= t event); void co_wrapper_mixed_bdrv_rdlock bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event); =20 +#define BLKDBG_CO_EVENT(child, evt) \ + do { \ + if (child) { \ + bdrv_co_debug_event(child->bs, evt); \ + } \ + } while (0) + #define BLKDBG_EVENT(child, evt) \ do { \ if (child) { \ --=20 2.40.1