From nobody Wed Apr 24 23:29:09 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=1669203900; cv=none; d=zohomail.com; s=zohoarc; b=DEVbf/x3JzrKA178f0jeH/uFb/aDhLadQIk5lMv7ruNBSIy5HI5A//PoknC6eTrsGHA2dg1qN+n+eDDIfarzGrS3LhDCQqm0HHYoqAsxOHheiRuSpskjSSc6VuncoYDtYs7hmmoaPhuJhq8xKuRXnnPBwh5YbLJ1hdLNJsiY3+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669203900; 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=EVLOM689IO0fBsaiwFiZAkp83bV2fu6b6ytbF3ybOLw=; b=BllRXtY1qMPuAoAYIqNLm+fONxaE7SJNSjwXJOgJj1VsU+KGcNi/EktJzZ0fkfuPbU0Cgcr/1aE0ljOj8YjdWYruAWn3aucQus2gpVxTy/Kz+0gLryu5fiP8HeRaXTl6gmVEOIowBPj4iIJ32OUn7KWaWtDA44jZQZqNqbI7wHI= 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 1669203900593383.2401206913288; Wed, 23 Nov 2022 03:45:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxo9J-0002el-4b; Wed, 23 Nov 2022 06:42:41 -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 1oxo9E-0002aV-QT for qemu-devel@nongnu.org; Wed, 23 Nov 2022 06:42:36 -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 1oxo9C-000607-WB for qemu-devel@nongnu.org; Wed, 23 Nov 2022 06:42:36 -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-592-wpHTTjDwP8iT6o43sptSnQ-1; Wed, 23 Nov 2022 06:42:31 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8D6A1C05EB6; Wed, 23 Nov 2022 11:42:30 +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 6DB86C2C8CA; Wed, 23 Nov 2022 11:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669203754; 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=EVLOM689IO0fBsaiwFiZAkp83bV2fu6b6ytbF3ybOLw=; b=FbKVepVTr1BXghHzW9WRV84G6qZjGHgkYYGUiS7oSppIMcV/5v/sX5zTy8FGPVfVTnRKb9 1GzmwtkPa1VIMaoW5pYvXcDkLaB6Fb7S9Iy6BkyIrJ7T30hh3mmmGBaN53acE1FffDGUqd fi3JZmz1AvbZqlAOhrc+eYS29BoFYjk= X-MC-Unique: wpHTTjDwP8iT6o43sptSnQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , Stefan Hajnoczi , "Denis V. Lunev" , Stefan Weil , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito , Paolo Bonzini Subject: [PATCH v5 02/15] block-copy: add missing coroutine_fn annotations Date: Wed, 23 Nov 2022 06:42:14 -0500 Message-Id: <20221123114227.85757-3-eesposit@redhat.com> In-Reply-To: <20221123114227.85757-1-eesposit@redhat.com> References: <20221123114227.85757-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1669203903127100003 Content-Type: text/plain; charset="utf-8" These functions end up calling bdrv_common_block_status_above(), a generated_co_wrapper function. In addition, they also happen to be always called in coroutine context, meaning all callers are coroutine_fn. This means that the g_c_w function will enter the qemu_in_coroutine() case and eventually suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- block/block-copy.c | 21 ++++++++++++--------- include/block/block-copy.h | 5 +++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index bb947afdda..5e59d6262f 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; @@ -590,8 +591,8 @@ static int block_copy_block_status(BlockCopyState *s, i= nt64_t offset, base =3D NULL; } =20 - ret =3D bdrv_block_status_above(s->source->bs, base, offset, bytes, &n= um, - NULL, NULL); + ret =3D bdrv_co_block_status_above(s->source->bs, base, offset, bytes,= &num, + NULL, NULL); if (ret < 0 || num < s->cluster_size) { /* * On error or if failed to obtain large enough chunk just fallbac= k to @@ -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; @@ -624,7 +626,7 @@ static int block_copy_is_cluster_allocated(BlockCopySta= te *s, int64_t offset, assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); =20 while (true) { - ret =3D bdrv_is_allocated(bs, offset, bytes, &count); + ret =3D bdrv_co_is_allocated(bs, offset, bytes, &count); if (ret < 0) { return ret; } @@ -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; diff --git a/include/block/block-copy.h b/include/block/block-copy.h index ba0b425d78..8cea4f9b90 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -36,8 +36,9 @@ void block_copy_set_progress_meter(BlockCopyState *s, Pro= gressMeter *pm); void block_copy_state_free(BlockCopyState *s); =20 void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes); -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); =20 int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t byt= es, bool ignore_ratelimit, uint64_t timeout_ns, --=20 2.31.1