From nobody Fri May 17 05:00:16 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=1668588726; cv=none; d=zohomail.com; s=zohoarc; b=dNz915dIlmeawbDW6ghSma/8mr7bKku/mImMtfwfBBZJl11VvsXt5/olUXmvHJCPiQ2VfZngX5UOWX4wagoeiKAmBp07Th77BhhCY7yUZClJeQtSKN/Bmx3zauUVfkgbWuK1I4RR/ndX5100Y+RZBDM4zR5bFI+evtmcylHE3dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588726; h=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=JtrAb69emIyJfaZ1jFBfok1HzANk2Q6v3g6UNTDkSMM=; b=C+WoTVmOwn8bh4FTxj7WDKyeRd80Gnu7ZGgaeftKdUauoQawLZu6qQvmie25OTBJWh/C2D6YpRIDOxkbBHkpgc4C/b4R4G2IMQHTWF+lrbuHr/ZVNCcQRBqLvD58YBvCNTnLG4DDySG3HDR1fkRKRvfqMBharD1ox+9FBw515po= 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 1668588726261566.6768928788528; Wed, 16 Nov 2022 00:52:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE9B-0002xu-MY; Wed, 16 Nov 2022 03:51:53 -0500 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 1ovE8Z-0002Zm-9D for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:15 -0500 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 1ovE8V-0003pY-HG for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:14 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-b47YrAj8MpmuDCKdJOeHQw-1; Wed, 16 Nov 2022 03:51:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F377A2A5956F; Wed, 16 Nov 2022 08:51:00 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B91012028E94; Wed, 16 Nov 2022 08:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JtrAb69emIyJfaZ1jFBfok1HzANk2Q6v3g6UNTDkSMM=; b=J2Yx0BPNuSB4z1AHBA8dCe59IM+AIHsGIIGneZ3PwvYzETxFGpXUPN3jllYSHG2tfSa/uL gL3fuEd1wKmR7lHO/JX0EPfV1tPeoDCQbDI/sIr4Zas+e5syESsqkZwTpwHq3OBRpTwNv7 YYbLjUfSQ8i9j2iZ2CoUyvqWUGnbR/g= X-MC-Unique: b47YrAj8MpmuDCKdJOeHQw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 1/8] block-copy: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 03:50:43 -0500 Message-Id: <20221116085050.2295179-2-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588727836100005 Content-Type: text/plain; charset="utf-8" block_copy_reset_unallocated and block_copy_is_cluster_allocated are only called by backup_run, a corotuine_fn itself. Same applies to block_copy_block_status, called by block_copy_dirty_clusters. Therefore mark them as coroutine too. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-copy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index bb947afdda..f33ab1d0b6 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -577,8 +577,9 @@ static coroutine_fn int block_copy_task_entry(AioTask *= task) return ret; } =20 -static int block_copy_block_status(BlockCopyState *s, int64_t offset, - int64_t bytes, int64_t *pnum) +static coroutine_fn int block_copy_block_status(BlockCopyState *s, + int64_t offset, + int64_t bytes, int64_t *pn= um) { int64_t num; BlockDriverState *base; @@ -613,8 +614,9 @@ static int block_copy_block_status(BlockCopyState *s, i= nt64_t offset, * Check if the cluster starting at offset is allocated or not. * return via pnum the number of contiguous clusters sharing this allocati= on. */ -static int block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offs= et, - int64_t *pnum) +static int coroutine_fn block_copy_is_cluster_allocated(BlockCopyState *s, + int64_t offset, + int64_t *pnum) { BlockDriverState *bs =3D s->source->bs; int64_t count, total_count =3D 0; @@ -669,8 +671,9 @@ void block_copy_reset(BlockCopyState *s, int64_t offset= , int64_t bytes) * @return 0 when the cluster at @offset was unallocated, * 1 otherwise, and -ret on error. */ -int64_t block_copy_reset_unallocated(BlockCopyState *s, - int64_t offset, int64_t *count) +int64_t coroutine_fn block_copy_reset_unallocated(BlockCopyState *s, + int64_t offset, + int64_t *count) { int ret; int64_t clusters, bytes; --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588720; cv=none; d=zohomail.com; s=zohoarc; b=EHXTp4YffD90hE6wo9xljymRWfzc+WowefHCd+eI48ajQl3I4vOe6XKLFdifoOUpSUtqIDTC4e5bn/iNy+V+ySFL8l6Gj8+IAHfo41XclbxrGPkrKvhdXytLZ/CbE3HzNyh0tM+c1mGfEipQTYq2wxtm0cbpYxT2070J826hGkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588720; h=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=kIkjCCV8qh5D0MYVN+kHOVhGXdf742Cag3/Z4cdiMXk=; b=T7HiPqEYvsSNV8en8wVNHmf8Tl9lPE6S7bzSjqUVFvWRvpCc1dxNWXuKPm1hLAZKpd8V+jLu0m04qWaQKaufEXQghM1q99NR3dl0D5PyJLqghhajDm8fXnsYBft++RsasjEGXiboOkWmJYK2MAx5OF9+T6YRLI1rhyAlgSotK50= 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 1668588720196935.6052863147538; Wed, 16 Nov 2022 00:52:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8Z-0002Zb-JE; Wed, 16 Nov 2022 03:51:15 -0500 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 1ovE8V-0002YK-Qd for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:11 -0500 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 1ovE8P-0003pH-Sn for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:10 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-tKX7RTirMiil7ZYHFShf1w-1; Wed, 16 Nov 2022 03:51:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 443521C0897B; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 082D520290A5; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kIkjCCV8qh5D0MYVN+kHOVhGXdf742Cag3/Z4cdiMXk=; b=gHPSlQlTQYA/tyHVU0ubxq2LdaCas1m75hmhQlUQ+oErb204TLQfHM8YUubTwanp2K7pQO gAMRxCa6vTUtGtfydszWaGFNbQY3Zr1XfO59UBamiezUE/5WCn9j3mpvIeKY4bwpYOlmRD N6RhggU64qy1ahWmefNGaFTPFsLSVzQ= X-MC-Unique: tKX7RTirMiil7ZYHFShf1w-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 2/8] nbd/server.c: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 03:50:44 -0500 Message-Id: <20221116085050.2295179-3-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588722402100001 Content-Type: text/plain; charset="utf-8" There are probably more missing, but right now it is necessary that we extend coroutine_fn to block{allock/status}_to_extents, because they use bdrv_* functions calling the generated_co_wrapper API, which checks for the qemu_in_coroutine() case. Signed-off-by: Emanuele Giuseppe Esposito --- nbd/server.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index ada16089f3..e2eec0cf46 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2141,8 +2141,9 @@ static int nbd_extent_array_add(NBDExtentArray *ea, return 0; } =20 -static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, NBDExtentArray *ea) +static int coroutine_fn blockstatus_to_extents(BlockDriverState *bs, + uint64_t offset, uint64_t b= ytes, + NBDExtentArray *ea) { while (bytes) { uint32_t flags; @@ -2168,8 +2169,9 @@ static int blockstatus_to_extents(BlockDriverState *b= s, uint64_t offset, return 0; } =20 -static int blockalloc_to_extents(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, NBDExtentArray *ea) +static int coroutine_fn blockalloc_to_extents(BlockDriverState *bs, + uint64_t offset, uint64_t by= tes, + NBDExtentArray *ea) { while (bytes) { int64_t num; @@ -2220,11 +2222,12 @@ static int nbd_co_send_extents(NBDClient *client, u= int64_t handle, } =20 /* Get block status from the exported device and send it to the client */ -static int nbd_co_send_block_status(NBDClient *client, uint64_t handle, - BlockDriverState *bs, uint64_t offset, - uint32_t length, bool dont_fragment, - bool last, uint32_t context_id, - Error **errp) +static int +coroutine_fn nbd_co_send_block_status(NBDClient *client, uint64_t handle, + BlockDriverState *bs, uint64_t offse= t, + uint32_t length, bool dont_fragment, + bool last, uint32_t context_id, + Error **errp) { int ret; unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BLOCK_STATUS_E= XTENTS; --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588761; cv=none; d=zohomail.com; s=zohoarc; b=TjxcflwmUko6reH0i/sS9uR71V1H0Fc1ezxfBM4aelAosWsDZVOHH0Cpz86qAsSl2aAwNSdhlkMdnvbc03fx2SgDbeHGrJ5XIdBFxaGyl9oUFxYwCgfJPibvzPpecUZ8JZgHsY2P4fUsDAO0RVRYSQ6NKypVKrmznC2px8tyY+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588761; h=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=/Uv4PNZFN+zxsbrgetlR7t4y9+evYoUIYXl0+parj+8=; b=VqbGAuM9vvAtOpl00BkXpSWKkslEHd30/fmjVNjar/670mC7kxG1ENfIDnejkFORlasODYi/1Ds84TDtc13ONb145b5dbdkGw9fqed/a/POq8OO+9BiKPNTq3ZFAkuENGJLlb7/XcScV+RTLP1gPWGUyc5+x/S+TOgAXbY1jrwM= 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 1668588761535330.26673461231576; Wed, 16 Nov 2022 00:52:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8g-0002hG-8l; Wed, 16 Nov 2022 03:51:22 -0500 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 1ovE8V-0002YL-RK for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:11 -0500 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 1ovE8O-0003ol-Dx for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:08 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-203-I170nTFLM3ynr6wiT2mkzg-1; Wed, 16 Nov 2022 03:51:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 869501C0896C; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C4BA2028E8F; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Uv4PNZFN+zxsbrgetlR7t4y9+evYoUIYXl0+parj+8=; b=iJ9b80j8XjmElh9i9J4HLo2g1xOAzAwwqfs+n3XMJnQYyJRMrGIioHYZjWMJt0Plxn4WPB zkdO5Y07/JP+2Iz3xJDYSEKU3ufNpVoL6+wRaJ0pLUCezPIvChRrQD3wjDpbLWCtSgkleD AqlEDigyC8Ppv0H6Vgp2bhP9TZ6MaxM= X-MC-Unique: I170nTFLM3ynr6wiT2mkzg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 3/8] block-backend: replace bdrv_*_above with blk_*_above Date: Wed, 16 Nov 2022 03:50:45 -0500 Message-Id: <20221116085050.2295179-4-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588762076100001 Content-Type: text/plain; charset="utf-8" Avoid mixing bdrv_* functions with blk_*, so create blk_* counterparts for: - bdrv_block_status_above - bdrv_is_allocated_above Note that these functions will take the rdlock, so they must always run in a coroutine. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 21 +++++++++++++++++++++ block/commit.c | 4 ++-- include/sysemu/block-backend-io.h | 9 +++++++++ nbd/server.c | 28 ++++++++++++++-------------- qemu-img.c | 4 ++-- 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 742efa7955..333d50fb3f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1424,6 +1424,27 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, i= nt64_t offset, return blk_co_pwritev_part(blk, offset, bytes, qiov, 0, flags); } =20 +int coroutine_fn blk_block_status_above(BlockBackend *blk, + BlockDriverState *base, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) +{ + IO_CODE(); + return bdrv_block_status_above(blk_bs(blk), base, offset, bytes, pnum,= map, + file); +} + +int coroutine_fn blk_is_allocated_above(BlockBackend *blk, + BlockDriverState *base, + bool include_base, int64_t offset, + int64_t bytes, int64_t *pnum) +{ + IO_CODE(); + return bdrv_is_allocated_above(blk_bs(blk), base, include_base, offset, + bytes, pnum); +} + typedef struct BlkRwCo { BlockBackend *blk; int64_t offset; diff --git a/block/commit.c b/block/commit.c index 0029b31944..9d4d908344 100644 --- a/block/commit.c +++ b/block/commit.c @@ -155,8 +155,8 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) break; } /* Copy if allocated above the base */ - ret =3D bdrv_is_allocated_above(blk_bs(s->top), s->base_overlay, t= rue, - offset, COMMIT_BUFFER_SIZE, &n); + ret =3D blk_is_allocated_above(s->top, s->base_overlay, true, + offset, COMMIT_BUFFER_SIZE, &n); copy =3D (ret > 0); trace_commit_one_iteration(s, offset, n, ret); if (copy) { diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 50f5aa2e07..a47cb825e5 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -92,6 +92,15 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in,= int64_t off_in, int64_t bytes, BdrvRequestFlags read_fl= ags, BdrvRequestFlags write_flags); =20 +int coroutine_fn blk_block_status_above(BlockBackend *blk, + BlockDriverState *base, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file); +int coroutine_fn blk_is_allocated_above(BlockBackend *blk, + BlockDriverState *base, + bool include_base, int64_t offset, + int64_t bytes, int64_t *pnum); =20 /* * "I/O or GS" API functions. These functions can run without diff --git a/nbd/server.c b/nbd/server.c index e2eec0cf46..6389b46396 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1991,7 +1991,7 @@ static int coroutine_fn nbd_co_send_structured_error(= NBDClient *client, } =20 /* Do a sparse read and send the structured reply to the client. - * Returns -errno if sending fails. bdrv_block_status_above() failure is + * Returns -errno if sending fails. blk_block_status_above() failure is * reported to the client, at which point this function succeeds. */ static int coroutine_fn nbd_co_send_sparse_read(NBDClient *client, @@ -2007,10 +2007,10 @@ static int coroutine_fn nbd_co_send_sparse_read(NBD= Client *client, =20 while (progress < size) { int64_t pnum; - int status =3D bdrv_block_status_above(blk_bs(exp->common.blk), NU= LL, - offset + progress, - size - progress, &pnum, NULL, - NULL); + int status =3D blk_block_status_above(exp->common.blk, NULL, + offset + progress, + size - progress, &pnum, NULL, + NULL); bool final; =20 if (status < 0) { @@ -2141,14 +2141,14 @@ static int nbd_extent_array_add(NBDExtentArray *ea, return 0; } =20 -static int coroutine_fn blockstatus_to_extents(BlockDriverState *bs, +static int coroutine_fn blockstatus_to_extents(BlockBackend *blk, uint64_t offset, uint64_t b= ytes, NBDExtentArray *ea) { while (bytes) { uint32_t flags; int64_t num; - int ret =3D bdrv_block_status_above(bs, NULL, offset, bytes, &num, + int ret =3D blk_block_status_above(blk, NULL, offset, bytes, &num, NULL, NULL); =20 if (ret < 0) { @@ -2169,13 +2169,13 @@ static int coroutine_fn blockstatus_to_extents(Bloc= kDriverState *bs, return 0; } =20 -static int coroutine_fn blockalloc_to_extents(BlockDriverState *bs, +static int coroutine_fn blockalloc_to_extents(BlockBackend *blk, uint64_t offset, uint64_t by= tes, NBDExtentArray *ea) { while (bytes) { int64_t num; - int ret =3D bdrv_is_allocated_above(bs, NULL, false, offset, bytes, + int ret =3D blk_is_allocated_above(blk, NULL, false, offset, bytes, &num); =20 if (ret < 0) { @@ -2224,7 +2224,7 @@ static int nbd_co_send_extents(NBDClient *client, uin= t64_t handle, /* Get block status from the exported device and send it to the client */ static int coroutine_fn nbd_co_send_block_status(NBDClient *client, uint64_t handle, - BlockDriverState *bs, uint64_t offse= t, + BlockBackend *blk, uint64_t offset, uint32_t length, bool dont_fragment, bool last, uint32_t context_id, Error **errp) @@ -2234,9 +2234,9 @@ coroutine_fn nbd_co_send_block_status(NBDClient *clie= nt, uint64_t handle, g_autoptr(NBDExtentArray) ea =3D nbd_extent_array_new(nb_extents); =20 if (context_id =3D=3D NBD_META_ID_BASE_ALLOCATION) { - ret =3D blockstatus_to_extents(bs, offset, length, ea); + ret =3D blockstatus_to_extents(blk, offset, length, ea); } else { - ret =3D blockalloc_to_extents(bs, offset, length, ea); + ret =3D blockalloc_to_extents(blk, offset, length, ea); } if (ret < 0) { return nbd_co_send_structured_error( @@ -2563,7 +2563,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, =20 if (client->export_meta.base_allocation) { ret =3D nbd_co_send_block_status(client, request->handle, - blk_bs(exp->common.blk), + exp->common.blk, request->from, request->len, dont_fragment, !--contexts_remaining, @@ -2576,7 +2576,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, =20 if (client->export_meta.allocation_depth) { ret =3D nbd_co_send_block_status(client, request->handle, - blk_bs(exp->common.blk), + exp->common.blk, request->from, request->len, dont_fragment, !--contexts_remaining, diff --git a/qemu-img.c b/qemu-img.c index a3b64c88af..4282a34bc0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1730,8 +1730,8 @@ static int convert_iteration_sectors(ImgConvertState = *s, int64_t sector_num) do { count =3D n * BDRV_SECTOR_SIZE; =20 - ret =3D bdrv_block_status_above(src_bs, base, offset, count, &= count, - NULL, NULL); + ret =3D bdrv_block_status_above(src_bs, base, offset, count, + &count, NULL, NULL); =20 if (ret < 0) { if (s->salvage) { --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588787; cv=none; d=zohomail.com; s=zohoarc; b=NGY+ESxD31XhbAclXeDiyrQKt08rCxF2SjXZKcNNMazjDGdQpDZsInCjgFnxYYOiFfbSRz+Slwcibpstw5qAlfl3GZ6uDBPAV4g2GCVJPg3+hoTE/sGRT3H1qpV60qwjp4a9Madan7p/UEq9A4IzQAVYDr9qe7jRElazJFyusgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588787; h=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=v2KR+wuQjHvkVKk+61cQotURv0168uQXyum+oiDyKeo=; b=Kc3ymXhPniUXCvhnY2bQmoq5elImUi5BTqlIzHdRfqJPwmGE6+42L5tMZSrr+yvjphMiwPHRSD2LCG7X0j+GCebU3KXynBLlycPAFlhYcWaAwCBeH5rlLRiH9okKk4hhIqoPom+M5LxlAOliCwTCyywiR3ZEDB9nA+M0vSg++hQ= 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 16685887871239.353777896892325; Wed, 16 Nov 2022 00:53:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8j-0002lA-F8; Wed, 16 Nov 2022 03:51:25 -0500 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 1ovE8c-0002br-TM for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:21 -0500 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 1ovE8X-0003rW-OR for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:16 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-340-ddPSDqcIPli06REasM-Ghw-1; Wed, 16 Nov 2022 03:51:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9973381A72C; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F6FE2028E8F; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v2KR+wuQjHvkVKk+61cQotURv0168uQXyum+oiDyKeo=; b=HCI11YZf5SvLtpG8R4LGWu0hsmMtAh/qVsm712Nev1+vIMx/8QdgCSyJS4C2L/Fv853m/e L+tAi+8jDqlYpw3+CzQQCQ9HNRG0xbgHF6WgTBKrM1NuaCS5wl+fX6OCb6XSuMT1MP4ZAN 6uJOzZjs2/5DZ8G+6IPMDROK1OEfzkg= X-MC-Unique: ddPSDqcIPli06REasM-Ghw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 4/8] block: distinguish between bdrv_create running in coroutine and not Date: Wed, 16 Nov 2022 03:50:46 -0500 Message-Id: <20221116085050.2295179-5-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588788212100003 Content-Type: text/plain; charset="utf-8" Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in bdrv_create(). It will also be useful when we add the graph rdlock to the coroutine case. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 74 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/block.c b/block.c index 577639c7e0..375c8056a3 100644 --- a/block.c +++ b/block.c @@ -528,66 +528,64 @@ typedef struct CreateCo { Error *err; } CreateCo; =20 -static void coroutine_fn bdrv_create_co_entry(void *opaque) +static int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filen= ame, + QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; int ret; + GLOBAL_STATE_CODE(); + assert(*errp =3D=3D NULL); + + if (!drv->bdrv_co_create_opts) { + error_setg(errp, "Driver '%s' does not support image creation", + drv->format_name); + return -ENOTSUP; + } + + ret =3D drv->bdrv_co_create_opts(drv, filename, opts, errp); =20 + if (ret < 0 && !*errp) { + error_setg_errno(errp, -ret, "Could not create image"); + } + + return ret; +} + +static void coroutine_fn bdrv_create_co_entry(void *opaque) +{ CreateCo *cco =3D opaque; - assert(cco->drv); GLOBAL_STATE_CODE(); + assert(cco->drv); =20 - ret =3D cco->drv->bdrv_co_create_opts(cco->drv, - cco->filename, cco->opts, &local_e= rr); - error_propagate(&cco->err, local_err); - cco->ret =3D ret; + cco->ret =3D bdrv_co_create(cco->drv, cco->filename, cco->opts, &cco->= err); } =20 int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp) { - int ret; - GLOBAL_STATE_CODE(); =20 - Coroutine *co; - CreateCo cco =3D { - .drv =3D drv, - .filename =3D g_strdup(filename), - .opts =3D opts, - .ret =3D NOT_DONE, - .err =3D NULL, - }; - - if (!drv->bdrv_co_create_opts) { - error_setg(errp, "Driver '%s' does not support image creation", dr= v->format_name); - ret =3D -ENOTSUP; - goto out; - } - if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ - bdrv_create_co_entry(&cco); + return bdrv_co_create(drv, filename, opts, errp); } else { + Coroutine *co; + CreateCo cco =3D { + .drv =3D drv, + .filename =3D g_strdup(filename), + .opts =3D opts, + .ret =3D NOT_DONE, + .err =3D NULL, + }; + co =3D qemu_coroutine_create(bdrv_create_co_entry, &cco); qemu_coroutine_enter(co); while (cco.ret =3D=3D NOT_DONE) { aio_poll(qemu_get_aio_context(), true); } + error_propagate(errp, cco.err); + g_free(cco.filename); + return cco.ret; } - - ret =3D cco.ret; - if (ret < 0) { - if (cco.err) { - error_propagate(errp, cco.err); - } else { - error_setg_errno(errp, -ret, "Could not create image"); - } - } - -out: - g_free(cco.filename); - return ret; } =20 /** --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588725; cv=none; d=zohomail.com; s=zohoarc; b=m/DgNKnbglrrQ5lHcEJpm5rwWnhUmRATB+oNAPMB0cTd9NQosTlYOQyknlyzbC7jWs8s1c8rKdhoKG0pBauxwHn2n3InKzDjWm1zosBfnz5/LeBg6d2JVSVm3FebgddgP+DOj0MpvGZy6NyWcOuAYqb4LREFpgJmRuUB/HOkPP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588725; h=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=R8Y6MqeY9uMftCHi6j1YVmdZ2ZBL/Gmr9aHkUtAGbI0=; b=TQUeHbzJnHIPIVh9at0vtx1IvHO6suh8RZUv8zhf4ymm2GJJsbxu6m5JxAdKsB/RCTb/q7Ktu7qCEXlQSjdot2QAxF08szPJdsebLl4E8FoqLrmYKE31H7R44Bm9mBmWWyYrb44dT0Nz+yUrCjjtEuAYai/YK0B/vKtKNJRd12g= 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 1668588725950406.2630897603615; Wed, 16 Nov 2022 00:52:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8s-0002p3-EI; Wed, 16 Nov 2022 03:51:36 -0500 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 1ovE8b-0002bn-Rm for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:21 -0500 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 1ovE8V-0003pb-IU for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:16 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-i9sw3if9OFm7Qt_CQjoDFA-1; Wed, 16 Nov 2022 03:51:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18E8985A5B6; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C3D20290A5; Wed, 16 Nov 2022 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R8Y6MqeY9uMftCHi6j1YVmdZ2ZBL/Gmr9aHkUtAGbI0=; b=YU+hP/767LMsGYg2nZh+VZ78LFC34UBNWPxOoW2VXHdcguOLyynNai6plQIF7X6/Lwa+BG iXEW7t3sIWg9HqzYR3guI/5X2OJy5WYaqrjfpNLFSQgcBR3CYIj7/HIENr3n2S2kgxNDjX mbTWeOFErFTEmmmiTCl1Z6aB+hNfYAg= X-MC-Unique: i9sw3if9OFm7Qt_CQjoDFA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 5/8] block/vmdk: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 03:50:47 -0500 Message-Id: <20221116085050.2295179-6-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588727838100006 Content-Type: text/plain; charset="utf-8" vmdk_co_create_opts() is a coroutine_fn, and calls vmdk_co_do_create() which in turn can call two callbacks: vmdk_co_create_opts_cb and vmdk_co_create_cb. Mark all these functions as coroutine_fn, since vmdk_co_create_opts() is the only caller. Signed-off-by: Emanuele Giuseppe Esposito --- block/vmdk.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 26376352b9..0c32bf2e83 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2285,10 +2285,11 @@ exit: return ret; } =20 -static int vmdk_create_extent(const char *filename, int64_t filesize, - bool flat, bool compress, bool zeroed_grain, - BlockBackend **pbb, - QemuOpts *opts, Error **errp) +static int coroutine_fn vmdk_create_extent(const char *filename, + int64_t filesize, bool flat, + bool compress, bool zeroed_grai= n, + BlockBackend **pbb, + QemuOpts *opts, Error **errp) { int ret; BlockBackend *blk =3D NULL; @@ -2366,14 +2367,14 @@ static int filename_decompose(const char *filename,= char *path, char *prefix, * non-split format. * idx >=3D 1: get the n-th extent if in a split subformat */ -typedef BlockBackend *(*vmdk_create_extent_fn)(int64_t size, - int idx, - bool flat, - bool split, - bool compress, - bool zeroed_grain, - void *opaque, - Error **errp); +typedef BlockBackend * coroutine_fn (*vmdk_create_extent_fn)(int64_t size, + int idx, + bool flat, + bool split, + bool compress, + bool zeroed_g= rain, + void *opaque, + Error **errp); =20 static void vmdk_desc_add_extent(GString *desc, const char *extent_line_fmt, @@ -2616,7 +2617,7 @@ typedef struct { QemuOpts *opts; } VMDKCreateOptsData; =20 -static BlockBackend *vmdk_co_create_opts_cb(int64_t size, int idx, +static BlockBackend * coroutine_fn vmdk_co_create_opts_cb(int64_t size, in= t idx, bool flat, bool split, bool co= mpress, bool zeroed_grain, void *opaqu= e, Error **errp) @@ -2768,10 +2769,11 @@ exit: return ret; } =20 -static BlockBackend *vmdk_co_create_cb(int64_t size, int idx, - bool flat, bool split, bool compres= s, - bool zeroed_grain, void *opaque, - Error **errp) +static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx, + bool flat, bool split, + bool compress, + bool zeroed_grain, + void *opaque, Error *= *errp) { int ret; BlockDriverState *bs; --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588986; cv=none; d=zohomail.com; s=zohoarc; b=dmmWH/yOYymLX7dYKvPivmY2+zyBbQkbQPR0+OLvLvR/3tzLiarLUy8vrXhVww22XNy7NlSQntrxFEKP/BKGK3svdwwyglktTRhyIJBuYfLi7gmlr7eclj+MSClS7WTgkX23EqYY5IKegqS2oKL2Xeqnarvl66qzfbh/T5+S2rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588986; h=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=yVXj54ioc/02CWEgM09JG/gEavxbxMR7SA1LjBazzt0=; b=doZKGGop/qmlm9eUSZb2G7Am3EyU41bqKL4yu/UugFRjoigWt8hmoOBNxGmpYW1wQnh7zo8WHUrPGkpUXzTtrkqsACSlPYRfBzQ8kWQGRQoCi/9SxX4TonrKEA6jJ8KINubgMOjLR8WsNmpOq8wEoj5sBSYF31f7yM/nTjXIDz4= 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 1668588986149865.7931266511742; Wed, 16 Nov 2022 00:56:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8h-0002iJ-Ms; Wed, 16 Nov 2022 03:51:23 -0500 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 1ovE8Y-0002Zk-4s for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:15 -0500 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 1ovE8V-0003pk-HB for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:13 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-bkXLSUvHPBmlItOGj-IX4g-1; Wed, 16 Nov 2022 03:51:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C0A9185A7AA; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21BE52023A16; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yVXj54ioc/02CWEgM09JG/gEavxbxMR7SA1LjBazzt0=; b=bOa1ZWdwllzouKuowFAkHPlVmwJyMS9fKE213HXoEX4QhF3H2YTvwdg10paoRrjaWMoflL qTJSBj2N4t+69wkJzrqzJWcfdn9eJpdcEu+DabhxSplnvcSyaA0uPHlcAm6hlMFj02RQx6 +V87y/ieL+Cq0vQYtCXZ2FBYJNH9NTk= X-MC-Unique: bkXLSUvHPBmlItOGj-IX4g-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 6/8] block: bdrv_create_file is a coroutine_fn Date: Wed, 16 Nov 2022 03:50:48 -0500 Message-Id: <20221116085050.2295179-7-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588988376100003 Content-Type: text/plain; charset="utf-8" It is always called in coroutine_fn callbacks, therefore it can directly call bdrv_co_create(). Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 6 ++++-- include/block/block-global-state.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 375c8056a3..dcac28756c 100644 --- a/block.c +++ b/block.c @@ -533,6 +533,7 @@ static int coroutine_fn bdrv_co_create(BlockDriver *drv= , const char *filename, { int ret; GLOBAL_STATE_CODE(); + assert(qemu_in_coroutine()); assert(*errp =3D=3D NULL); =20 if (!drv->bdrv_co_create_opts) { @@ -723,7 +724,8 @@ out: return ret; } =20 -int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp) +int coroutine_fn bdrv_create_file(const char *filename, QemuOpts *opts, + Error **errp) { QemuOpts *protocol_opts; BlockDriver *drv; @@ -764,7 +766,7 @@ int bdrv_create_file(const char *filename, QemuOpts *op= ts, Error **errp) goto out; } =20 - ret =3D bdrv_create(drv, filename, protocol_opts, errp); + ret =3D bdrv_co_create(drv, filename, protocol_opts, errp); out: qemu_opts_del(protocol_opts); qobject_unref(qdict); diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 00e0cf8aea..6f35ed99e3 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -57,7 +57,8 @@ BlockDriver *bdrv_find_protocol(const char *filename, BlockDriver *bdrv_find_format(const char *format_name); int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp); -int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); +int coroutine_fn bdrv_create_file(const char *filename, QemuOpts *opts, + Error **errp); =20 BlockDriverState *bdrv_new(void); int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588746; cv=none; d=zohomail.com; s=zohoarc; b=EdFIvFKy9zDtSFI8d1oSEWyoDeaZCLGcVeoxnXpwRUgd9GDhQnqJJ3udLb5tqhlQV6We5180+qvWrHz3utj4bkGKaX2sXM6JA8sPydSQ3G6E8r+CPA6ONDwWJENr/E+iD5YvljISoj97MlIzxeHjk2LykUzheF/ui+zGXwB8CkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588746; h=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=l5/RjdUrrSizYq0xEUqvVDmTRuvXC6c6saEwuVt2lpM=; b=LUBl9OeE8TwaDQvg3FFW3t4gWmiP2Tq0/M3qZ+r2yUcByu2xLbC0SspSGiEGlJacEMcmYmEZqUOu50AGhezGWGhPIMoAClB5h2jGZLgiwfADMHpV8xai2Yhjgp96ggQh4Yq2EA/kg3Wpu1WnPA06vgXFmY7bu4bxSHlBhNKN/9k= 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 1668588746133482.11209823174477; Wed, 16 Nov 2022 00:52:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8i-0002jN-Hv; Wed, 16 Nov 2022 03:51:24 -0500 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 1ovE8Z-0002Zn-B4 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:15 -0500 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 1ovE8V-0003pm-H3 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:15 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-55-VbJXA2xXPAyDuS5oWae8lA-1; Wed, 16 Nov 2022 03:51:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FCDD803481; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64CB92028E8F; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l5/RjdUrrSizYq0xEUqvVDmTRuvXC6c6saEwuVt2lpM=; b=AOZNDXfWbwXlkq6sFJA+96mdvv+FsrvB7h+V9giu6GRyyev54xKSx7uJcnuo/wt49jUkxy sr3r0tHx1Hu+xKC6WMg+aON3IBogGBDfluPtB1RneFN6js9TCxkXmrreW8JGYAGvjHZpI8 56woXS/ZI2FP5jNmExqjWN1W//TiNOU= X-MC-Unique: VbJXA2xXPAyDuS5oWae8lA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 7/8] block: bdrv_create is never called in coroutine context Date: Wed, 16 Nov 2022 03:50:49 -0500 Message-Id: <20221116085050.2295179-8-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588747965100003 Content-Type: text/plain; charset="utf-8" Delete the if case and make sure it won't be called again in coroutines. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/block.c b/block.c index dcac28756c..7a4ce7948c 100644 --- a/block.c +++ b/block.c @@ -563,30 +563,25 @@ static void coroutine_fn bdrv_create_co_entry(void *o= paque) int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp) { + Coroutine *co; + CreateCo cco =3D { + .drv =3D drv, + .filename =3D g_strdup(filename), + .opts =3D opts, + .ret =3D NOT_DONE, + .err =3D NULL, + }; GLOBAL_STATE_CODE(); + assert(!qemu_in_coroutine()); =20 - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - return bdrv_co_create(drv, filename, opts, errp); - } else { - Coroutine *co; - CreateCo cco =3D { - .drv =3D drv, - .filename =3D g_strdup(filename), - .opts =3D opts, - .ret =3D NOT_DONE, - .err =3D NULL, - }; - - co =3D qemu_coroutine_create(bdrv_create_co_entry, &cco); - qemu_coroutine_enter(co); - while (cco.ret =3D=3D NOT_DONE) { - aio_poll(qemu_get_aio_context(), true); - } - error_propagate(errp, cco.err); - g_free(cco.filename); - return cco.ret; + co =3D qemu_coroutine_create(bdrv_create_co_entry, &cco); + qemu_coroutine_enter(co); + while (cco.ret =3D=3D NOT_DONE) { + aio_poll(qemu_get_aio_context(), true); } + error_propagate(errp, cco.err); + g_free(cco.filename); + return cco.ret; } =20 /** --=20 2.31.1 From nobody Fri May 17 05:00:16 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=1668588721; cv=none; d=zohomail.com; s=zohoarc; b=Ss8oo2NeUVR4Ux0T7A05tKaKpwYDAXkgZ0RZ3anGwwIGs/MZmaT9tGSKKDYdM6MAChhYR9TXvdb+EtmxEVZHhzm+i29t76HoDpM3vOaars1HUoNr0CYA/1VNVYHmfLPXk+btNGx5ahKY26fs2TjvJTI8QJjRrFh3i5cTUoTpPLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668588721; h=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=9oy0eVZd2AWHWE0gSeNL+AiME+JCmB8NOawj7bmt9bE=; b=eiMSPL6vgoSPV05VoYnjfbjOpQbCsC5OSQhA/wxiaaQEXrtiJO1GuiutpoPG3Cem7eD197XU6RJhna1QExPyGPi1+OBu/F1Vl2VpYV3gsApxtwHYunHIqMYg6i7VtvsCnXLX17cMjwOozLbbf3NrsQb+nFFnDDFC+KlwL3vDwNg= 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 1668588721165552.6270079824842; Wed, 16 Nov 2022 00:52:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovE8i-0002ik-3A; Wed, 16 Nov 2022 03:51:24 -0500 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 1ovE8V-0002YM-RL for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:11 -0500 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 1ovE8P-0003p7-ED for qemu-devel@nongnu.org; Wed, 16 Nov 2022 03:51:09 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-55-6VmgDbrOPWSZWQfDhV-kgA-1; Wed, 16 Nov 2022 03:51:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3428381A733; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A862220290A5; Wed, 16 Nov 2022 08:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668588664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9oy0eVZd2AWHWE0gSeNL+AiME+JCmB8NOawj7bmt9bE=; b=QvEdcYr8iR8ElXovhhJMiw9Od37WSA6SiSjczrdWANmgCIEf1znsG0lRKgIc2vGsmNvyMi IPWuzEoVruOfXRnOeZZfFBz+3ayzQ0dVTBon0YAfbX6wPOii++S6K+h8gxD9H72g+nJ5ru 9Qv729m3iFcMdERMgoelFokR8/Au/qs= X-MC-Unique: 6VmgDbrOPWSZWQfDhV-kgA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v3 8/8] block/dirty-bitmap: remove unnecessary qemu_in_coroutine() case Date: Wed, 16 Nov 2022 03:50:50 -0500 Message-Id: <20221116085050.2295179-9-eesposit@redhat.com> In-Reply-To: <20221116085050.2295179-1-eesposit@redhat.com> References: <20221116085050.2295179-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=eesposit@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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1668588722457100003 Content-Type: text/plain; charset="utf-8" Some functions check if they are running in a coroutine, calling the coroutine callback directly if it's the case. Except that no coroutine calls such functions, therefore that case can be removed. Signed-off-by: Emanuele Giuseppe Esposito --- block/dirty-bitmap.c | 66 +++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index bf3dc0512a..8092d08261 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -418,24 +418,20 @@ bdrv_co_remove_persistent_dirty_bitmap_entry(void *op= aque) int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *= name, Error **errp) { - if (qemu_in_coroutine()) { - return bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp); - } else { - Coroutine *co; - BdrvRemovePersistentDirtyBitmapCo s =3D { - .bs =3D bs, - .name =3D name, - .errp =3D errp, - .ret =3D -EINPROGRESS, - }; - - co =3D qemu_coroutine_create(bdrv_co_remove_persistent_dirty_bitma= p_entry, - &s); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, s.ret =3D=3D -EINPROGRESS); - - return s.ret; - } + Coroutine *co; + BdrvRemovePersistentDirtyBitmapCo s =3D { + .bs =3D bs, + .name =3D name, + .errp =3D errp, + .ret =3D -EINPROGRESS, + }; + assert(!qemu_in_coroutine()); + co =3D qemu_coroutine_create(bdrv_co_remove_persistent_dirty_bitmap_en= try, + &s); + bdrv_coroutine_enter(bs, co); + BDRV_POLL_WHILE(bs, s.ret =3D=3D -EINPROGRESS); + + return s.ret; } =20 bool @@ -494,25 +490,21 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState= *bs, const char *name, uint32_t granularity, Error **errp) { IO_CODE(); - if (qemu_in_coroutine()) { - return bdrv_co_can_store_new_dirty_bitmap(bs, name, granularity, e= rrp); - } else { - Coroutine *co; - BdrvCanStoreNewDirtyBitmapCo s =3D { - .bs =3D bs, - .name =3D name, - .granularity =3D granularity, - .errp =3D errp, - .in_progress =3D true, - }; - - co =3D qemu_coroutine_create(bdrv_co_can_store_new_dirty_bitmap_en= try, - &s); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, s.in_progress); - - return s.ret; - } + Coroutine *co; + BdrvCanStoreNewDirtyBitmapCo s =3D { + .bs =3D bs, + .name =3D name, + .granularity =3D granularity, + .errp =3D errp, + .in_progress =3D true, + }; + assert(!qemu_in_coroutine()); + co =3D qemu_coroutine_create(bdrv_co_can_store_new_dirty_bitmap_entry, + &s); + bdrv_coroutine_enter(bs, co); + BDRV_POLL_WHILE(bs, s.in_progress); + + return s.ret; } =20 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap) --=20 2.31.1