From nobody Sat May 18 23:23:25 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=1668607796; cv=none; d=zohomail.com; s=zohoarc; b=SL3lr2CWx2CTFy+jVNuxGf8UykDZ98PlXhEL2UBF4gf4Iso3+wOs/IhYjeazX0GSG1lSXZADpal/qurDqzW24SJmMcQaKOTHqgbFd/EUJ44m6SJIMRRp3DfNHIqzn5rHo6D2FenK5MzGNnbCklBCXiB5HHF4635ev/ZwreHApJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607796; 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=VqdJNgSPR2iME7QV2e49ms+m6C5NJ4Lp+mVdOpZtzx8=; b=kh9UCsmXVP2Zlvi+JiGVPqqnsBxDkZqD2sZyP4WVqLap80iGvU5naYG72wGaBt1Aizp3ttsqBP3wqBCcJj9ytBXB3uXManN3gqmcGmsnmkYHXan2S45jLqdyz5GdSlVrICPysaF1ZCYodVifNlN8pLVTU6tzG78sEL489HCHP20= 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 1668607796504701.4904219555252; Wed, 16 Nov 2022 06:09:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ55-0001Ea-Ei; Wed, 16 Nov 2022 09:07:59 -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 1ovJ4v-0000pT-4I for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:51 -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 1ovJ4q-00067t-2D for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:47 -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-520-8F8lMmVYM1mLHYfgabJSSQ-1; Wed, 16 Nov 2022 09:07:35 -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 CC8053810D3E; Wed, 16 Nov 2022 14:07:34 +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 3C54BC2C8C7; Wed, 16 Nov 2022 14:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607660; 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=VqdJNgSPR2iME7QV2e49ms+m6C5NJ4Lp+mVdOpZtzx8=; b=JZh21jJB+Ll1WQ5e15+aXAGgYvcl68C3e9FXeZxMM6tR056WiDa9GNoaB9AqRNPmtV97YX faVSbYlkJVjltXqi0OOPy6c/yfTiTGweuKhmZFSsaMVzmNXTfWQO9IvTKAKTrWXF5QWQPt 7peRb7ymlZpyEjU/7GQ6j2v7QBYoL+Q= X-MC-Unique: 8F8lMmVYM1mLHYfgabJSSQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 01/15] block/qed: add missing graph rdlock in qed_need_check_timer_entry Date: Wed, 16 Nov 2022 09:07:16 -0500 Message-Id: <20221116140730.3056048-2-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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=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: 1668607796950100001 Content-Type: text/plain; charset="utf-8" This function is called in two different places: - timer callback, which does not take the graph rdlock. - bdrv_qed_drain_begin(), which is a .bdrv_drain_begin() callback that will soon take the lock. Since it calls recursive functions that traverse the graph, we need to protect them with the graph rdlock. Signed-off-by: Emanuele Giuseppe Esposito --- block/qed.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/qed.c b/block/qed.c index c2691a85b1..778b23d0f6 100644 --- a/block/qed.c +++ b/block/qed.c @@ -282,11 +282,13 @@ static void coroutine_fn qed_unplug_allocating_write_= reqs(BDRVQEDState *s) qemu_co_mutex_unlock(&s->table_lock); } =20 +/* Called with graph rdlock taken */ static void coroutine_fn qed_need_check_timer(BDRVQEDState *s) { int ret; =20 trace_qed_need_check_timer_cb(s); + assert_bdrv_graph_readable(); =20 if (!qed_plug_allocating_write_reqs(s)) { return; @@ -312,6 +314,7 @@ static void coroutine_fn qed_need_check_timer(BDRVQEDSt= ate *s) static void coroutine_fn qed_need_check_timer_entry(void *opaque) { BDRVQEDState *s =3D opaque; + GRAPH_RDLOCK_GUARD(); =20 qed_need_check_timer(opaque); bdrv_dec_in_flight(s->bs); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607983; cv=none; d=zohomail.com; s=zohoarc; b=nfKt8oyVc0UXlX+7j9Nu05Gmuysr7/7GLhWoyjWiR9vZpCbjZK2wULclfPNdvT0zH3Uw7ebHNwR6ooWHkpv15Vbhqys9vu9HAcAT5JHfpiwKsA+S8t2e5tNEYNqnFvITq9Xox0kOXG2t0DtLuiVHnN7M1Jf7vEwqaq1myFaJAQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607983; 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=WKjbvCBHfWczLtZ4W4XK4ekyG4Mj/cWzo96rN1QJT1s=; b=ZsrghHRbPAjgy/t4VeQMH3o6I12IylJedxyogJSUQz+MUd+rVNhiNM93WWzzlWpLmrn5ik954Zh7gnNX0QpAi4O/1PwRb0zZ/vbvE1Mz0QzPQozmCNirlrKrb1Tt5SYcZrJBBPSY1VHG7aZtJ1O9oaPqEPnoTmT17Suk0T1Ej3Y= 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 1668607983341567.5504085506217; Wed, 16 Nov 2022 06:13:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ56-0001GM-94; Wed, 16 Nov 2022 09:08:00 -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 1ovJ4x-0000qi-5V for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:51 -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 1ovJ4q-00068Y-Sq for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:50 -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-341-E5c26S8FNRmq5zSBQzvMqg-1; Wed, 16 Nov 2022 09:07:36 -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 A8A421C087A2; Wed, 16 Nov 2022 14:07:35 +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 D643FC2C8C5; Wed, 16 Nov 2022 14:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607660; 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=WKjbvCBHfWczLtZ4W4XK4ekyG4Mj/cWzo96rN1QJT1s=; b=J5fO2ItC7JXiE7uTgXY8brNMoKNejz42LG3TmteWx5FXa3UXmSpGQ2MxBmWH+aIlHnXUnv K3jVw+z1a6t3b4jtQJSTZ11LreZNH30BB6eY7HVbPagzcV+SJMf2udULbPXcCK8LNI/wAc Gk+axM6SAzkX+TMuoSFfpjtAfcvEOw0= X-MC-Unique: E5c26S8FNRmq5zSBQzvMqg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 02/15] block: rename refresh_total_sectors in bdrv_refresh_total_sectors Date: Wed, 16 Nov 2022 09:07:17 -0500 Message-Id: <20221116140730.3056048-3-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607985571100005 Content-Type: text/plain; charset="utf-8" Name is not right, since we are going to convert this in a generated_co_wrapper. No functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 8 ++++---- block/io.c | 8 +++++--- include/block/block_int-io.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index 1a6ae08879..ba4bbb42aa 100644 --- a/block.c +++ b/block.c @@ -1044,7 +1044,7 @@ static int find_image_format(BlockBackend *file, cons= t char *filename, * Set the current 'total_sectors' value * Return 0 on success, -errno on error. */ -int refresh_total_sectors(BlockDriverState *bs, int64_t hint) +int bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint) { BlockDriver *drv =3D bs->drv; IO_CODE(); @@ -1662,7 +1662,7 @@ static int bdrv_open_driver(BlockDriverState *bs, Blo= ckDriver *drv, bs->supported_read_flags |=3D BDRV_REQ_REGISTERED_BUF; bs->supported_write_flags |=3D BDRV_REQ_REGISTERED_BUF; =20 - ret =3D refresh_total_sectors(bs, bs->total_sectors); + ret =3D bdrv_refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { error_setg_errno(errp, -ret, "Could not refresh total sector count= "); return ret; @@ -5783,7 +5783,7 @@ int64_t bdrv_nb_sectors(BlockDriverState *bs) return -ENOMEDIUM; =20 if (drv->has_variable_length) { - int ret =3D refresh_total_sectors(bs, bs->total_sectors); + int ret =3D bdrv_refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { return ret; } @@ -6565,7 +6565,7 @@ int bdrv_activate(BlockDriverState *bs, Error **errp) bdrv_dirty_bitmap_skip_store(bm, false); } =20 - ret =3D refresh_total_sectors(bs, bs->total_sectors); + ret =3D bdrv_refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { bs->open_flags |=3D BDRV_O_INACTIVE; error_setg_errno(errp, -ret, "Could not refresh total sector c= ount"); diff --git a/block/io.c b/block/io.c index 7d1d0c48b0..99867fe148 100644 --- a/block/io.c +++ b/block/io.c @@ -3411,15 +3411,17 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,= int64_t offset, bool exact, goto out; } =20 - ret =3D refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); + ret =3D bdrv_refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); if (ret < 0) { error_setg_errno(errp, -ret, "Could not refresh total sector count= "); } else { offset =3D bs->total_sectors * BDRV_SECTOR_SIZE; } - /* It's possible that truncation succeeded but refresh_total_sectors + /* + * It's possible that truncation succeeded but bdrv_refresh_total_sect= ors * failed, but the latter doesn't affect how we should finish the requ= est. - * Pass 0 as the last parameter so that dirty bitmaps etc. are handled= . */ + * Pass 0 as the last parameter so that dirty bitmaps etc. are handled. + */ bdrv_co_write_req_finish(child, offset - new_bytes, new_bytes, &req, 0= ); =20 out: diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index ac6ad3b3ff..453855e651 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -122,7 +122,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, = int64_t src_offset, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); =20 -int refresh_total_sectors(BlockDriverState *bs, int64_t hint); +int bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint); =20 BdrvChild *bdrv_cow_child(BlockDriverState *bs); BdrvChild *bdrv_filter_child(BlockDriverState *bs); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607698; cv=none; d=zohomail.com; s=zohoarc; b=YzCfDJ2CJPlDOkfACdVqUuxFlozr4pCk0esM/+98c/4a33+La6xJLY9lPuCB1fjMIqZulH0iDbaAcDd3bfUIVGZiTVkrDphUL8dXgN6yIf9ubTB31h+aNBqrYtNNoToeyyCKZsc9qe4RRC331d5Ui5J3/XrSnxU5BVajGi0s/BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607698; 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=i/lNceb3G1WdGUkMMa+Dm6IP1UjeETmtexFZxPttQBs=; b=PjYay3+9lsEptumiueyDzBUeeemRugNzNFAcpWLvC/OKlkXlzEDSNhxFko13ci0jg4CpvqUXjjdpcqZrIel0jemoaXzr9I76kH3WKBn04+tiZusP54P0q3+TExdP4rMSuI4vfKfshycaP/zA2a/q2mTymPk7L9DOHjKjZf2sRtk= 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 1668607698864479.4034018156592; Wed, 16 Nov 2022 06:08:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ50-0000wd-Bs; Wed, 16 Nov 2022 09:07:55 -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 1ovJ4s-0000kv-1G for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:46 -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 1ovJ4p-00068i-8P for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:45 -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-546-G35u6sXIM_qmzCCuq8H75g-1; Wed, 16 Nov 2022 09:07:37 -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 4D80D3C025B8; Wed, 16 Nov 2022 14:07:36 +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 B0B1DC2C8C9; Wed, 16 Nov 2022 14:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607661; 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=i/lNceb3G1WdGUkMMa+Dm6IP1UjeETmtexFZxPttQBs=; b=NzqxBlZkCl/ZyZy1EArpEuHiB1Vm8n19l13sZknZXemWVxlxcMTT7QUcVQAa66jtKjN8xS xPtIYnFN3a39fRzmV4UiM4/MqVdp8CTdo9iJodp/V563Fpm8zxLHcceyt1Uaa6jUR61ccF TAio5xmMRsae5tBuMDMYn3hK48/nC1Q= X-MC-Unique: G35u6sXIM_qmzCCuq8H75g-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 03/15] block-backend: use bdrv_getlength instead of blk_getlength Date: Wed, 16 Nov 2022 09:07:18 -0500 Message-Id: <20221116140730.3056048-4-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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: 1668607699818100001 Content-Type: text/plain; charset="utf-8" The only difference is that blk_ checks if the block is available, but this check is already performed above in blk_check_byte_request(). This is in preparation for the graph rdlock, which will be taken by both the callers of blk_check_byte_request() and blk_getlength(). Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 6f0dd15808..4af9a3179e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1253,7 +1253,7 @@ static int blk_check_byte_request(BlockBackend *blk, = int64_t offset, } =20 if (!blk->allow_write_beyond_eof) { - len =3D blk_getlength(blk); + len =3D bdrv_getlength(blk_bs(blk)); if (len < 0) { return len; } --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607792; cv=none; d=zohomail.com; s=zohoarc; b=KT7t/bzUg/AAwAjwL562Syrq/pFu2bNWkWnxjMocJlIA/oiqdLjNNF1N3UgWqy3aw0n60DzE2rDFY08Xx19l88sPD/YCHPFWCem6Giyn2dmO6OD19jL3K0GMW/9pus1jHAk9pP6HlIPH+JFFrccy1smZGPNXmGV0IfovxdssRXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607792; 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=YYxOQB89W5Wqm87Y3FpdXE1g9tJm1CFlSqDjzmCUIuY=; b=IFW7LoqFgHHA+guX+Hdc2Xc8BkOny9uXZbF6Eo2WwTmtq65dD8w7NEORVwOXZTn8zPvL7VWt3HiCium7ePRt7Hn7tOdIEcOmbtUzwS4WcYuLrhU7+NBMiwj95BHF10+sXmlUh1yMrndNlYwFLccC9lg5yu6rFg+N6oTXajuMpEQ= 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 1668607792342999.4663875205847; Wed, 16 Nov 2022 06:09:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ53-00018l-G0; Wed, 16 Nov 2022 09:07:57 -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 1ovJ4v-0000qL-T3 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:51 -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 1ovJ4q-000693-2V for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:49 -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-201-MZJaSnkPOS-rIo5bxp0Oow-1; Wed, 16 Nov 2022 09:07:38 -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 EC2823810D39; Wed, 16 Nov 2022 14:07:36 +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 5889FC2C8C7; Wed, 16 Nov 2022 14:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607662; 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=YYxOQB89W5Wqm87Y3FpdXE1g9tJm1CFlSqDjzmCUIuY=; b=IOshThOj+vyBmI65XNNeSEF93MZ8qgD7l+SLiYkqPWQp6MNzAATf1bC2DgdNsk1qSdv3NU XbWMz0/QMidR/5RwIVYRPUu1JzPc/sIZ6wii9+x93PGp3PUNoEySNznC2b12vkT2npL7iD NebsVS/VNfL/HDXJMsepjfR9kERSHV0= X-MC-Unique: MZJaSnkPOS-rIo5bxp0Oow-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 04/15] block: convert bdrv_refresh_total_sectors in generated_co_wrapper Date: Wed, 16 Nov 2022 09:07:19 -0500 Message-Id: <20221116140730.3056048-5-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607793185100005 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_getlength is categorized as IO callb ack, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, sin ce the callback traverses the block nodes graph. Therefore use generated_co_wrapper to automatically create a wrapper for bdrv_refresh_total_sectors. Unfortunately we cannot use a generated_co_wrapper_sim ple, because the function is called by mixed functions that run both in coroutine and non-coroutine context (for example bd rv_open_driver()). Unfortunately this callback requires multiple bdrv_* a nd blk_* callbacks to be converted, because there are different mixed callers (coroutines and not) calling this callback fro m different function paths. Because now this function creates a new coroutine and polls, we need to take the AioContext lock where it is missing, for the only reason that internally g_c_w calls AIO_WAIT_WHILE and it expects to release the AioContext lock. This is especially messy when a g_c_w creates a coroutine and polls in bdrv_open_driver, because this function has so many callers in so many context that it can easily lead to deadlocks. Therefore the new rule for bdrv_open_driver is that the caller must always hold the AioContext lock of the given bs (except if it is a coroutine), because the function calls bdrv_refresh_total_sectors() which is a g_c_w. Once the rwlock is ultimated and placed in every place it needs to be, we will poll using AIO_WAIT_WHILE_UNLOCKED and remove the AioContext lock. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 29 ++++++++++++++++++++++++----- block/block-backend.c | 12 ++++++++---- block/commit.c | 4 ++-- block/meson.build | 1 + block/mirror.c | 7 +++++-- hw/scsi/scsi-disk.c | 5 +++++ include/block/block-io.h | 8 ++++++-- include/block/block_int-common.h | 3 ++- include/block/block_int-io.h | 5 ++++- include/sysemu/block-backend-io.h | 10 ++++++++-- tests/unit/test-block-iothread.c | 7 +++++++ 11 files changed, 72 insertions(+), 19 deletions(-) diff --git a/block.c b/block.c index ba4bbb42aa..c7b32ba17a 100644 --- a/block.c +++ b/block.c @@ -1044,10 +1044,12 @@ static int find_image_format(BlockBackend *file, co= nst char *filename, * Set the current 'total_sectors' value * Return 0 on success, -errno on error. */ -int bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint) +int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs, + int64_t hint) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return -ENOMEDIUM; @@ -1611,6 +1613,11 @@ out: g_free(gen_node_name); } =20 +/* + * The caller must always hold @bs AioContext lock, because this function = calls + * bdrv_refresh_total_sectors() which polls when called from non-coroutine + * context. + */ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, QDict *options, int open_flags, Error **errp) @@ -3750,6 +3757,10 @@ out: * The reference parameter may be used to specify an existing block device= which * should be opened. If specified, neither options nor a filename may be g= iven, * nor can an existing BDS be reused (that is, *pbs has to be NULL). + * + * The caller must always hold @filename AioContext lock, because this + * function eventually calls bdrv_refresh_total_sectors() which polls + * when called from non-coroutine context. */ static BlockDriverState *bdrv_open_inherit(const char *filename, const char *reference, @@ -4038,6 +4049,11 @@ close_and_fail: return NULL; } =20 +/* + * The caller must always hold @filename AioContext lock, because this + * function eventually calls bdrv_refresh_total_sectors() which polls + * when called from non-coroutine context. + */ BlockDriverState *bdrv_open(const char *filename, const char *reference, QDict *options, int flags, Error **errp) { @@ -5774,16 +5790,17 @@ BlockMeasureInfo *bdrv_measure(BlockDriver *drv, Qe= muOpts *opts, /** * Return number of sectors on success, -errno on error. */ -int64_t bdrv_nb_sectors(BlockDriverState *bs) +int64_t coroutine_fn bdrv_co_nb_sectors(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) return -ENOMEDIUM; =20 if (drv->has_variable_length) { - int ret =3D bdrv_refresh_total_sectors(bs, bs->total_sectors); + int ret =3D bdrv_co_refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { return ret; } @@ -5795,11 +5812,13 @@ int64_t bdrv_nb_sectors(BlockDriverState *bs) * Return length in bytes on success, -errno on error. * The length is always a multiple of BDRV_SECTOR_SIZE. */ -int64_t bdrv_getlength(BlockDriverState *bs) +int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs) { - int64_t ret =3D bdrv_nb_sectors(bs); + int64_t ret; IO_CODE(); + assert_bdrv_graph_readable(); =20 + ret =3D bdrv_co_nb_sectors(bs); if (ret < 0) { return ret; } diff --git a/block/block-backend.c b/block/block-backend.c index 4af9a3179e..fc19cf423e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1603,14 +1603,16 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk= , int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } =20 -int64_t blk_getlength(BlockBackend *blk) +int64_t coroutine_fn blk_co_getlength(BlockBackend *blk) { IO_CODE(); + GRAPH_RDLOCK_GUARD(); + if (!blk_is_available(blk)) { return -ENOMEDIUM; } =20 - return bdrv_getlength(blk_bs(blk)); + return bdrv_co_getlength(blk_bs(blk)); } =20 void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr) @@ -1623,14 +1625,16 @@ void blk_get_geometry(BlockBackend *blk, uint64_t *= nb_sectors_ptr) } } =20 -int64_t blk_nb_sectors(BlockBackend *blk) +int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk) { IO_CODE(); + GRAPH_RDLOCK_GUARD(); + if (!blk_is_available(blk)) { return -ENOMEDIUM; } =20 - return bdrv_nb_sectors(blk_bs(blk)); + return bdrv_co_nb_sectors(blk_bs(blk)); } =20 BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, diff --git a/block/commit.c b/block/commit.c index 9d4d908344..986e7502eb 100644 --- a/block/commit.c +++ b/block/commit.c @@ -123,13 +123,13 @@ static int coroutine_fn commit_run(Job *job, Error **= errp) QEMU_AUTO_VFREE void *buf =3D NULL; int64_t len, base_len; =20 - len =3D blk_getlength(s->top); + len =3D blk_co_getlength(s->top); if (len < 0) { return len; } job_progress_set_remaining(&s->common.job, len); =20 - base_len =3D blk_getlength(s->base); + base_len =3D blk_co_getlength(s->base); if (base_len < 0) { return base_len; } diff --git a/block/meson.build b/block/meson.build index 90011a2805..3662852dc2 100644 --- a/block/meson.build +++ b/block/meson.build @@ -139,6 +139,7 @@ block_gen_c =3D custom_target('block-gen.c', input: files( '../include/block/block-io.h', '../include/block/dirty-bitmap.h', + '../include/block/block_int-io.h', '../include/block/block-global-state= .h', '../include/sysemu/block-backend-io.= h', 'coroutines.h' diff --git a/block/mirror.c b/block/mirror.c index 02ee7bba08..aecc895b73 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -915,13 +915,16 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) goto immediate_exit; } =20 - s->bdev_length =3D bdrv_getlength(bs); + bdrv_graph_co_rdlock(); + s->bdev_length =3D bdrv_co_getlength(bs); + bdrv_graph_co_rdunlock(); + if (s->bdev_length < 0) { ret =3D s->bdev_length; goto immediate_exit; } =20 - target_length =3D blk_getlength(s->target); + target_length =3D blk_co_getlength(s->target); if (target_length < 0) { ret =3D target_length; goto immediate_exit; diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e493c28814..d4e360850f 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2332,10 +2332,15 @@ static void scsi_disk_reset(DeviceState *dev) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev.qdev, dev); uint64_t nb_sectors; + AioContext *ctx; =20 scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET)); =20 + ctx =3D blk_get_aio_context(s->qdev.conf.blk); + aio_context_acquire(ctx); blk_get_geometry(s->qdev.conf.blk, &nb_sectors); + aio_context_release(ctx); + nb_sectors /=3D s->qdev.blocksize / BDRV_SECTOR_SIZE; if (nb_sectors) { nb_sectors--; diff --git a/include/block/block-io.h b/include/block/block-io.h index f45ef6206f..4fb95e9b7a 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -68,8 +68,12 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int6= 4_t offset, bool exact, PreallocMode prealloc, BdrvRequestFlags = flags, Error **errp); =20 -int64_t bdrv_nb_sectors(BlockDriverState *bs); -int64_t bdrv_getlength(BlockDriverState *bs); +int64_t coroutine_fn bdrv_co_nb_sectors(BlockDriverState *bs); +int64_t generated_co_wrapper bdrv_nb_sectors(BlockDriverState *bs); + +int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs); +int64_t generated_co_wrapper bdrv_getlength(BlockDriverState *bs); + int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, BlockDriverState *in_bs, Error **errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 00c581a712..d1cf52d4f7 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -723,7 +723,8 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_truncate)(BlockDriverState *bs, int64_t off= set, bool exact, PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp); - int64_t (*bdrv_getlength)(BlockDriverState *bs); + /* Called with graph rdlock held. */ + int64_t coroutine_fn (*bdrv_getlength)(BlockDriverState *bs); int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); =20 /* Does not need graph rdlock, since it does not traverse the graph */ diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index 453855e651..5794160a0f 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -122,7 +122,10 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src,= int64_t src_offset, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); =20 -int bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint); +int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs, + int64_t hint); +int generated_co_wrapper bdrv_refresh_total_sectors(BlockDriverState *bs, + int64_t hint); =20 BdrvChild *bdrv_cow_child(BlockDriverState *bs); BdrvChild *bdrv_filter_child(BlockDriverState *bs); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 887a29dc59..5456822b07 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -57,9 +57,15 @@ bool blk_is_inserted(BlockBackend *blk); bool blk_is_available(BlockBackend *blk); void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); -int64_t blk_getlength(BlockBackend *blk); + +int64_t coroutine_fn blk_co_getlength(BlockBackend *blk); +int64_t generated_co_wrapper_blk blk_getlength(BlockBackend *blk); + void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr); -int64_t blk_nb_sectors(BlockBackend *blk); + +int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk); +int64_t generated_co_wrapper_blk blk_nb_sectors(BlockBackend *blk); + void *blk_try_blockalign(BlockBackend *blk, size_t size); void *blk_blockalign(BlockBackend *blk, size_t size); bool blk_is_writable(BlockBackend *blk); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 8ca5adec5e..d2d69efd00 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -831,7 +831,14 @@ static void test_attach_second_node(void) qdict_put_str(options, "driver", "raw"); qdict_put_str(options, "file", "base"); =20 + /* + * Acquire iothread AioContext, since bs is in ctx and bdrv_open will + * call bdrv_refresh_total_sectors(), a generated_co_wrapper function + * that therefore expects ctx lock to be held. + */ + aio_context_acquire(ctx); filter =3D bdrv_open(NULL, NULL, options, BDRV_O_RDWR, &error_abort); + aio_context_release(ctx); g_assert(blk_get_aio_context(blk) =3D=3D ctx); g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); g_assert(bdrv_get_aio_context(filter) =3D=3D ctx); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668608094; cv=none; d=zohomail.com; s=zohoarc; b=YVx43+lYBVunl3GWs48ga/CSoI8mgeLZwxXfDOiURheX3G1Txz2i0LIu5TxjC2t13KMK2p5QsckC5o1xnKm/quVNd65cYsm4gtydUVl7AwbHTzfCfHjk4q01vn0WuAeQoFbwHVgzZKHpC7Qley3OiYZ4wLlFFbIp7YioErOd+5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668608094; 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=aSbumGyBQHztlg3imwPXMNJnG2wiSX+4N94DeWeRBMI=; b=TsDd7s0sFqln5jQbnwr2RiaCnDj9RC/P/TZRZPJ5QjWPnczANQ1HIVMxLefxJntGzQUGmVAMFVDHXUYDQ46TxS+M5QkrbvH+kjREPt/2NxHOIwSjDOF4Iek2gMgxBBUv3zDfbd7nm8z/EDy1VYQLMDoTrmbAmKusOWmLCLxvsxE= 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 1668608094164257.98447323316714; Wed, 16 Nov 2022 06:14:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ52-000112-85; Wed, 16 Nov 2022 09:07:56 -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 1ovJ4s-0000l9-WD for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:47 -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 1ovJ4q-00068P-1Q for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:46 -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-554-LMHVf8tVMs2Khcoi0OG54w-1; Wed, 16 Nov 2022 09:07:38 -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 90A7F3810D37; Wed, 16 Nov 2022 14:07:37 +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 019C6C2C8C9; Wed, 16 Nov 2022 14:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607660; 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=aSbumGyBQHztlg3imwPXMNJnG2wiSX+4N94DeWeRBMI=; b=QisKXrTXjGMAs4e0LDRv7cDuvMW4Fr6ptZAmTVQbITGEvPDMWtKzlL2AeWpDQ3XXUpR0EG XMUm7vOPL+JtJPs6v701Jl4I5OB2J7Mv3AlBxyFdh8sFoyVcTRoHoB6lus/53kczWFP2n0 IVLwk6UvYKpA8d1xDXXLIm6fPzRPoLI= X-MC-Unique: LMHVf8tVMs2Khcoi0OG54w-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 05/15] block: use bdrv_co_refresh_total_sectors when possible Date: Wed, 16 Nov 2022 09:07:20 -0500 Message-Id: <20221116140730.3056048-6-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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: 1668608095339100001 Content-Type: text/plain; charset="utf-8" In some places we are sure we are always running in a coroutine, therefore it's useless to call the generated_co_wrapper, instead call directly the _co_ function. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 6 +++--- block/copy-on-read.c | 2 +- block/io.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index fc19cf423e..6a84a2a019 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1235,8 +1235,8 @@ void blk_set_disable_request_queuing(BlockBackend *bl= k, bool disable) blk->disable_request_queuing =3D disable; } =20 -static int blk_check_byte_request(BlockBackend *blk, int64_t offset, - int64_t bytes) +static coroutine_fn int blk_check_byte_request(BlockBackend *blk, + int64_t offset, int64_t byt= es) { int64_t len; =20 @@ -1253,7 +1253,7 @@ static int blk_check_byte_request(BlockBackend *blk, = int64_t offset, } =20 if (!blk->allow_write_beyond_eof) { - len =3D bdrv_getlength(blk_bs(blk)); + len =3D bdrv_co_getlength(blk_bs(blk)); if (len < 0) { return len; } diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 815ac1d835..74f7727a02 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -122,7 +122,7 @@ static void cor_child_perm(BlockDriverState *bs, BdrvCh= ild *c, =20 static int64_t cor_getlength(BlockDriverState *bs) { - return bdrv_getlength(bs->file->bs); + return bdrv_co_getlength(bs->file->bs); } =20 =20 diff --git a/block/io.c b/block/io.c index 99867fe148..3f65c57f82 100644 --- a/block/io.c +++ b/block/io.c @@ -3381,7 +3381,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, if (new_bytes && backing) { int64_t backing_len; =20 - backing_len =3D bdrv_getlength(backing->bs); + backing_len =3D bdrv_co_getlength(backing->bs); if (backing_len < 0) { ret =3D backing_len; error_setg_errno(errp, -ret, "Could not get backing file size"= ); @@ -3411,7 +3411,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, goto out; } =20 - ret =3D bdrv_refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); + ret =3D bdrv_co_refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); if (ret < 0) { error_setg_errno(errp, -ret, "Could not refresh total sector count= "); } else { --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607908; cv=none; d=zohomail.com; s=zohoarc; b=CpaiIlrx8lz1wqk8OIDSeS89Jwm506Mm9q9p3QNrqHVxCTHFDAiDc+IXSLzdj1yu2RyIxI5lQQhqQ6ONy2BSf1Jq6uPyIE54Cxahvqhol+aUsLZH0l7VuDlL8mNWDq+aM0fc/iOnxibwxItTPtub4tD0fMma8J1uZS8zsvWgxBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607908; 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=ofv4pS8f2mCmUoMSq24yvD4pA5jOYOOMvJoBvadaHDk=; b=ercCSraWOcEtaMCxyaSf/62iI8asSzpU6dNwEkKdem/RUhNeaF/qi0NqATgksgDzo+1hZO59x+IB36b80QEsgrNyxfwzKzh1+vj1m2+Hcw/ax4zGky0X6O2pwdV8jW7PPF7PmsZrX7M+nisJ30fqs+2YGzlS/PnKIuZJz8r5ogA= 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 16686079089464.370920559175602; Wed, 16 Nov 2022 06:11:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ51-0000wp-Fi; Wed, 16 Nov 2022 09:07:55 -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 1ovJ4s-0000l6-Om for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:47 -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 1ovJ4q-00068C-1N for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:46 -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-558-nQCHXKHoPtyrVf3x2v9Zkg-1; Wed, 16 Nov 2022 09:07:39 -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 365B63810D3B; Wed, 16 Nov 2022 14:07:38 +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 9A64BC1908A; Wed, 16 Nov 2022 14:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607660; 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=ofv4pS8f2mCmUoMSq24yvD4pA5jOYOOMvJoBvadaHDk=; b=TWojiLY4YU6pZrXLOuBNRPOQEnRYScuXhRNo1t+Cajqqx9gfOZrw/km82YPXpUSherMgqT WVXYkkuEQkdnpUwQ1PJavV/gw9TNb7lm8P6+nnzUa4dWHiiEXXqBB2D3kAkv4hwIxJcUKk V0NvFRRB7RXO2XDpG65UunSRgE2gHSo= X-MC-Unique: nQCHXKHoPtyrVf3x2v9Zkg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 06/15] block: convert bdrv_get_allocated_file_size in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:21 -0500 Message-Id: <20221116140730.3056048-7-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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=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: 1668607910353100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_get_allocated_file_size is categorized as IO callback, a= nd it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. Therefore use generated_co_wrapper_simple to automatically create a wrapper with the same name that will take care of always calling the function in a coroutine. This is a generated_co_wrapper_simple callback, which means it assumes that bdrv_get_allocated_file_size is never caled in a coroutine context. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 7 ++++--- block/qcow2-refcount.c | 2 +- include/block/block-io.h | 5 ++++- include/block/block_int-common.h | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index c7b32ba17a..5650d6fe63 100644 --- a/block.c +++ b/block.c @@ -5708,7 +5708,7 @@ static int64_t bdrv_sum_allocated_file_size(BlockDriv= erState *bs) if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA | BDRV_CHILD_FILTERED)) { - child_size =3D bdrv_get_allocated_file_size(child->bs); + child_size =3D bdrv_co_get_allocated_file_size(child->bs); if (child_size < 0) { return child_size; } @@ -5723,10 +5723,11 @@ static int64_t bdrv_sum_allocated_file_size(BlockDr= iverState *bs) * Length of a allocated file in bytes. Sparse files are counted by actual * allocated space. Return < 0 if error or unknown. */ -int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) +int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return -ENOMEDIUM; @@ -5744,7 +5745,7 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState= *bs) return -ENOTSUP; } else if (drv->is_filter) { /* Filter drivers default to the size of their filtered child */ - return bdrv_get_allocated_file_size(bdrv_filter_bs(bs)); + return bdrv_co_get_allocated_file_size(bdrv_filter_bs(bs)); } else { /* Other drivers default to summing their children's sizes */ return bdrv_sum_allocated_file_size(bs); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 81264740f0..487681d85e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -3719,7 +3719,7 @@ int coroutine_fn qcow2_detect_metadata_preallocation(= BlockDriverState *bs) return file_length; } =20 - real_allocation =3D bdrv_get_allocated_file_size(bs->file->bs); + real_allocation =3D bdrv_co_get_allocated_file_size(bs->file->bs); if (real_allocation < 0) { return real_allocation; } diff --git a/include/block/block-io.h b/include/block/block-io.h index 4fb95e9b7a..ac509c461f 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -74,7 +74,10 @@ int64_t generated_co_wrapper bdrv_nb_sectors(BlockDriver= State *bs); int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs); int64_t generated_co_wrapper bdrv_getlength(BlockDriverState *bs); =20 -int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); +int64_t generated_co_wrapper_simple bdrv_get_allocated_file_size( + BlockDriverState *= bs); +int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs); + BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, BlockDriverState *in_bs, Error **errp); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index d1cf52d4f7..42daf86c65 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -725,7 +725,8 @@ struct BlockDriver { BdrvRequestFlags flags, Error **e= rrp); /* Called with graph rdlock held. */ int64_t coroutine_fn (*bdrv_getlength)(BlockDriverState *bs); - int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); + /* Called with graph rdlock held. */ + int64_t coroutine_fn (*bdrv_get_allocated_file_size)(BlockDriverState = *bs); =20 /* Does not need graph rdlock, since it does not traverse the graph */ BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in= _bs, --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607797; cv=none; d=zohomail.com; s=zohoarc; b=NbBzG+KWh/9uJpvyuRFUzqYdHkqvty3z+1naFl4BCyKdWps3fJrmqO6MeZeoSAd7AUudUw1Qccl+YRfD2ZykSpqk633tHTlb69nTt01ZAuR+FNqcYNG+hCSQEP60PNxXXfcdgEkhl5cMi5RcRbptsRtIjLPl8Ej2nTFxodXr0tE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607797; 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=Hwngj/ABa/x3wWMfoUyD4dyNgWdM0OqY2IrBe1CnYOo=; b=cDR17loA8izlbfawXhaoZP1Hb2La9sHo91mayEGJY3yW9nkwGy5WpAFPEb5xvcKJ5q0kqciV78y+8kk2Gj/cWyI2A/PW25cVFGw/KZyHode/OY5B0kapG9U0h2R7Y8DaLnxkoO0LX0oQRx+qhOjinircepe5cF08TQKHM2fFVLo= 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 1668607797933879.2800353637967; Wed, 16 Nov 2022 06:09:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ56-0001Gd-Dn; Wed, 16 Nov 2022 09:08:00 -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 1ovJ4z-0000uL-KL for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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 1ovJ4q-00069H-Po for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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-245-9rHptg98Mgi-ImvoAFtazw-1; Wed, 16 Nov 2022 09:07:40 -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 D107286F132; Wed, 16 Nov 2022 14:07:38 +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 4026CC1908A; Wed, 16 Nov 2022 14:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607663; 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=Hwngj/ABa/x3wWMfoUyD4dyNgWdM0OqY2IrBe1CnYOo=; b=b4LXxP2KLBDXbF4Bz+1QMbjnAlG22LgrNDdOhDp1qS2Vv2aVV3B4ZZ5Vu2//EP0Lugo2/V 5UqHlIVUoFLXpWi5FMr6Qd/lEzUTUraEZdsqdYYYs6Xs4QUMnEJB3oQtxAEXaNcKPN7uZh 51QjLoBFTkb5+VjY7XfQSsciUbbehm4= X-MC-Unique: 9rHptg98Mgi-ImvoAFtazw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 07/15] block: convert bdrv_get_info in generated_co_wrapper Date: Wed, 16 Nov 2022 09:07:22 -0500 Message-Id: <20221116140730.3056048-8-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607799599100005 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_get_info is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. Therefore use generated_co_wrapper to automatically create a wrapper with the same name. Unfortunately we cannot use a generated_co_wrapper_simple, because the function is called by mixed functions that run both in coroutine and non-coroutine context (for example block_load in migration/block.c). Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 6 ++++-- block/crypto.c | 2 +- block/io.c | 8 ++++---- block/mirror.c | 10 +++++++--- block/raw-format.c | 2 +- block/stream.c | 4 +++- include/block/block-io.h | 6 +++++- include/block/block_int-common.h | 4 +++- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 5650d6fe63..2cdede9c01 100644 --- a/block.c +++ b/block.c @@ -6279,11 +6279,13 @@ void bdrv_get_backing_filename(BlockDriverState *bs, pstrcpy(filename, filename_size, bs->backing_file); } =20 -int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *b= di) { int ret; BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); + /* if bs->drv =3D=3D NULL, bs is closed, so there's nothing to do here= */ if (!drv) { return -ENOMEDIUM; @@ -6291,7 +6293,7 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverIn= fo *bdi) if (!drv->bdrv_get_info) { BlockDriverState *filtered =3D bdrv_filter_bs(bs); if (filtered) { - return bdrv_get_info(filtered, bdi); + return bdrv_co_get_info(filtered, bdi); } return -ENOTSUP; } diff --git a/block/crypto.c b/block/crypto.c index 2fb8add458..12a84dd1cd 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -743,7 +743,7 @@ static int block_crypto_get_info_luks(BlockDriverState = *bs, BlockDriverInfo subbdi; int ret; =20 - ret =3D bdrv_get_info(bs->file->bs, &subbdi); + ret =3D bdrv_co_get_info(bs->file->bs, &subbdi); if (ret !=3D 0) { return ret; } diff --git a/block/io.c b/block/io.c index 3f65c57f82..99ef9a8cb9 100644 --- a/block/io.c +++ b/block/io.c @@ -694,14 +694,14 @@ BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_req= uest(BlockDriverState *bs) /** * Round a region to cluster boundaries */ -void bdrv_round_to_clusters(BlockDriverState *bs, +void coroutine_fn bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *cluster_offset, int64_t *cluster_bytes) { BlockDriverInfo bdi; IO_CODE(); - if (bdrv_get_info(bs, &bdi) < 0 || bdi.cluster_size =3D=3D 0) { + if (bdrv_co_get_info(bs, &bdi) < 0 || bdi.cluster_size =3D=3D 0) { *cluster_offset =3D offset; *cluster_bytes =3D bytes; } else { @@ -711,12 +711,12 @@ void bdrv_round_to_clusters(BlockDriverState *bs, } } =20 -static int bdrv_get_cluster_size(BlockDriverState *bs) +static coroutine_fn int bdrv_get_cluster_size(BlockDriverState *bs) { BlockDriverInfo bdi; int ret; =20 - ret =3D bdrv_get_info(bs, &bdi); + ret =3D bdrv_co_get_info(bs, &bdi); if (ret < 0 || bdi.cluster_size =3D=3D 0) { return bs->bl.request_alignment; } else { diff --git a/block/mirror.c b/block/mirror.c index aecc895b73..8dc136ebbe 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -576,8 +576,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBl= ockJob *s) } else if (ret >=3D 0 && !(ret & BDRV_BLOCK_DATA)) { int64_t target_offset; int64_t target_bytes; - bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, - &target_offset, &target_bytes); + WITH_GRAPH_RDLOCK_GUARD() { + bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, + &target_offset, &target_bytes); + } if (target_offset =3D=3D offset && target_bytes =3D=3D io_bytes) { mirror_method =3D ret & BDRV_BLOCK_ZERO ? @@ -965,11 +967,13 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) */ bdrv_get_backing_filename(target_bs, backing_filename, sizeof(backing_filename)); - if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) { + bdrv_graph_co_rdlock(); + if (!bdrv_co_get_info(target_bs, &bdi) && bdi.cluster_size) { s->target_cluster_size =3D bdi.cluster_size; } else { s->target_cluster_size =3D BDRV_SECTOR_SIZE; } + bdrv_graph_co_rdunlock(); if (backing_filename[0] && !bdrv_backing_chain_next(target_bs) && s->granularity < s->target_cluster_size) { s->buf_size =3D MAX(s->buf_size, s->target_cluster_size); diff --git a/block/raw-format.c b/block/raw-format.c index a68014ef0b..4773bf9cda 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -369,7 +369,7 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, Bl= ockDriverState *in_bs, =20 static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { - return bdrv_get_info(bs->file->bs, bdi); + return bdrv_co_get_info(bs->file->bs, bdi); } =20 static void raw_refresh_limits(BlockDriverState *bs, Error **errp) diff --git a/block/stream.c b/block/stream.c index 22368ce186..6c9d0eefd1 100644 --- a/block/stream.c +++ b/block/stream.c @@ -141,7 +141,9 @@ static int coroutine_fn stream_run(Job *job, Error **er= rp) return 0; } =20 - len =3D bdrv_getlength(s->target_bs); + WITH_GRAPH_RDLOCK_GUARD() { + len =3D bdrv_getlength(s->target_bs); + } if (len < 0) { return len; } diff --git a/include/block/block-io.h b/include/block/block-io.h index ac509c461f..ba60ffa43b 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -129,7 +129,11 @@ bool bdrv_supports_compressed_writes(BlockDriverState = *bs); const char *bdrv_get_node_name(const BlockDriverState *bs); const char *bdrv_get_device_name(const BlockDriverState *bs); const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); -int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); + +int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *b= di); +int generated_co_wrapper bdrv_get_info(BlockDriverState *bs, + BlockDriverInfo *bdi); + ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, Error **errp); BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 42daf86c65..5874531617 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -740,7 +740,9 @@ struct BlockDriver { int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); =20 - int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); + /* Called with graph rdlock held. */ + int coroutine_fn (*bdrv_get_info)(BlockDriverState *bs, + BlockDriverInfo *bdi); =20 /* Does not need graph rdlock, since it does not traverse the graph */ ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs, --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668608076; cv=none; d=zohomail.com; s=zohoarc; b=F1Lnt7KlD4bYwQU9HUagq6De6jaA74Q2zZcCgGkuxZ7FFhvCBzkVDaIoKHYZZeWpVCjP1QIOe6VE+/tI/HqNKxW9MB2Sp334v4ildk0cBLd16o1Rey1CdlzRZyuKhHmU1ySN61GMeNud9avUjb13Nu4vTmXKcuA2JOu9B3vI08w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668608076; 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=NIsX+LPvxRYdxR0WN9B7+AR2K5URUVD5+nusU62oPIo=; b=UDRdUfUqxEHNtYINvuClfHohEbyKjAl1fueC6VTtttb9qQ+x7bRb31Cl1h3KMl9Cjpp1g2gZ5ZhB4SMSY+zmkascUFhCslSe/hZewlktgIyYACV3aLzj1oVlvW7wLonMDHG9r7yc5RPtPlKsM9iXeNo76GXe/nK3jeqV0Ct5i4g= 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 1668608076806616.2212756422743; Wed, 16 Nov 2022 06:14:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ54-0001C0-4u; Wed, 16 Nov 2022 09:07:58 -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 1ovJ4z-0000uA-6W for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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 1ovJ4s-0006AW-Aj for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:52 -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-643-jR_agOcFOGG-hWRiMA4KzA-1; Wed, 16 Nov 2022 09:07:40 -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 7CED0101A52A; Wed, 16 Nov 2022 14:07:39 +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 DB4DFC1908A; Wed, 16 Nov 2022 14:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607665; 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=NIsX+LPvxRYdxR0WN9B7+AR2K5URUVD5+nusU62oPIo=; b=NhFaRuMx9N3ETx5nULzl88uONKiML77BaH3J40yBVMBOf+qgL3FKx4SHp71WaChP8gkSD/ ZQDGHFWupPLa3991qaanBky/xi17CJ8FBATbSre/j+YtE1RcI5W2npKfSU3l5LZL6vQYl2 WY3u4mqHdmd/j/UT66Y7BmzkFl7QSC0= X-MC-Unique: jR_agOcFOGG-hWRiMA4KzA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 08/15] block: convert bdrv_is_inserted in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:23 -0500 Message-Id: <20221116140730.3056048-9-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668608077325100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_is_inserted is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. Therefore use generated_co_wrapper_simple to automatically creates a wrapper with the same name that will take care of always calling the function in a coroutine. This is a generated_co_wrapper_simple callback, which means it assumes that bdrv_is_inserted is never caled in a coroutine context. At the same time, add also blk_is_inserted as g_c_w, since it is called in both coroutine and non contexts. Because now this function creates a new coroutine and polls, we need to take the AioContext lock where it is missing, for the only reason that internally g_c_w calls AIO_WAIT_WHILE and it expects to release the AioContext lock. Once the rwlock is ultimated and placed in every place it needs to be, we will poll using AIO_WAIT_WHILE_UNLOCKED and remove the AioContext lock. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 5 +++-- block/block-backend.c | 5 +++-- block/io.c | 12 ++++++------ blockdev.c | 8 +++++++- include/block/block-io.h | 5 ++++- include/block/block_int-common.h | 4 ++-- include/sysemu/block-backend-io.h | 5 ++++- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index 2cdede9c01..4205735308 100644 --- a/block.c +++ b/block.c @@ -6778,11 +6778,12 @@ out: /** * Return TRUE if the media is present */ -bool bdrv_is_inserted(BlockDriverState *bs) +bool coroutine_fn bdrv_co_is_inserted(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; BdrvChild *child; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return false; @@ -6791,7 +6792,7 @@ bool bdrv_is_inserted(BlockDriverState *bs) return drv->bdrv_is_inserted(bs); } QLIST_FOREACH(child, &bs->children, next) { - if (!bdrv_is_inserted(child->bs)) { + if (!bdrv_co_is_inserted(child->bs)) { return false; } } diff --git a/block/block-backend.c b/block/block-backend.c index 6a84a2a019..9a500fdde3 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1994,12 +1994,13 @@ void blk_activate(BlockBackend *blk, Error **errp) bdrv_activate(bs, errp); } =20 -bool blk_is_inserted(BlockBackend *blk) +bool coroutine_fn blk_co_is_inserted(BlockBackend *blk) { BlockDriverState *bs =3D blk_bs(blk); IO_CODE(); + assert_bdrv_graph_readable(); =20 - return bs && bdrv_is_inserted(bs); + return bs && bdrv_co_is_inserted(bs); } =20 bool blk_is_available(BlockBackend *blk) diff --git a/block/io.c b/block/io.c index 99ef9a8cb9..88da9470c3 100644 --- a/block/io.c +++ b/block/io.c @@ -1598,7 +1598,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, =20 trace_bdrv_co_preadv_part(bs, offset, bytes, flags); =20 - if (!bdrv_is_inserted(bs)) { + if (!bdrv_co_is_inserted(bs)) { return -ENOMEDIUM; } =20 @@ -2044,7 +2044,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chil= d, =20 trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags); =20 - if (!bdrv_is_inserted(bs)) { + if (!bdrv_co_is_inserted(bs)) { return -ENOMEDIUM; } =20 @@ -2764,7 +2764,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) assert_bdrv_graph_readable(); bdrv_inc_in_flight(bs); =20 - if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || + if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs) || bdrv_is_sg(bs)) { goto early_exit; } @@ -2889,7 +2889,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, i= nt64_t offset, IO_CODE(); assert_bdrv_graph_readable(); =20 - if (!bs || !bs->drv || !bdrv_is_inserted(bs)) { + if (!bs || !bs->drv || !bdrv_co_is_inserted(bs)) { return -ENOMEDIUM; } =20 @@ -3173,7 +3173,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( assert(!(read_flags & BDRV_REQ_NO_WAIT)); assert(!(write_flags & BDRV_REQ_NO_WAIT)); =20 - if (!dst || !dst->bs || !bdrv_is_inserted(dst->bs)) { + if (!dst || !dst->bs || !bdrv_co_is_inserted(dst->bs)) { return -ENOMEDIUM; } ret =3D bdrv_check_request32(dst_offset, bytes, NULL, 0); @@ -3184,7 +3184,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( return bdrv_co_pwrite_zeroes(dst, dst_offset, bytes, write_flags); } =20 - if (!src || !src->bs || !bdrv_is_inserted(src->bs)) { + if (!src || !src->bs || !bdrv_co_is_inserted(src->bs)) { return -ENOMEDIUM; } ret =3D bdrv_check_request32(src_offset, bytes, NULL, 0); diff --git a/blockdev.c b/blockdev.c index 8ffb3d9537..bbe5207e8f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1023,6 +1023,7 @@ fail: static BlockDriverState *qmp_get_root_bs(const char *name, Error **errp) { BlockDriverState *bs; + AioContext *aio_context; =20 bs =3D bdrv_lookup_bs(name, name, errp); if (bs =3D=3D NULL) { @@ -1034,11 +1035,16 @@ static BlockDriverState *qmp_get_root_bs(const char= *name, Error **errp) return NULL; } =20 + aio_context =3D bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + if (!bdrv_is_inserted(bs)) { error_setg(errp, "Device has no medium"); - return NULL; + bs =3D NULL; } =20 + aio_context_release(aio_context); + return bs; } =20 diff --git a/include/block/block-io.h b/include/block/block-io.h index ba60ffa43b..3432e6ad3e 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -120,7 +120,10 @@ bool bdrv_is_read_only(BlockDriverState *bs); bool bdrv_is_writable(BlockDriverState *bs); bool bdrv_is_sg(BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); -bool bdrv_is_inserted(BlockDriverState *bs); + +bool coroutine_fn bdrv_co_is_inserted(BlockDriverState *bs); +bool generated_co_wrapper_simple bdrv_is_inserted(BlockDriverState *bs); + void bdrv_lock_medium(BlockDriverState *bs, bool locked); void bdrv_eject(BlockDriverState *bs, bool eject_flag); const char *bdrv_get_format_name(BlockDriverState *bs); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 5874531617..4cad48b2ad 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -759,8 +759,8 @@ struct BlockDriver { QEMUIOVector *qiov, int64_t pos); =20 - /* removable device specific */ - bool (*bdrv_is_inserted)(BlockDriverState *bs); + /* removable device specific. Called with graph rdlock held. */ + bool coroutine_fn (*bdrv_is_inserted)(BlockDriverState *bs); void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); =20 diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 5456822b07..bf88f7699e 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -53,7 +53,10 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned lo= ng int req, void *buf, =20 void blk_inc_in_flight(BlockBackend *blk); void blk_dec_in_flight(BlockBackend *blk); -bool blk_is_inserted(BlockBackend *blk); + +bool coroutine_fn blk_co_is_inserted(BlockBackend *blk); +bool generated_co_wrapper blk_is_inserted(BlockBackend *blk); + bool blk_is_available(BlockBackend *blk); void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607921; cv=none; d=zohomail.com; s=zohoarc; b=bPy3EDBDdFZS4QTn/Gued4fPAS/Hc6ZiZ4JQwR7MhwDHRr0ZN0bMNCzgsrT0Sz+WRjup0z4XdGAikJNtwd4iEmy8NX600J8ET/tHVMLZnELTYJZYvzJnkDRYozhS1a2rJFjHM3XGQk0tE/6ovEYcn8J/pBZGsKCt00l7NY4e6Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607921; 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=OwLDLnzEP3/wR4BUpGqG03oyOcX+DzKDBTWtcaqpOzE=; b=ETOkRfWSL1ATq+rudPMyT6hh+4S929eOiMmqRjSLmbnPYJiP89bH3z78GxNXzwrIscSYQ/X4hH460be3vDkD8hop++lgyTeJjN0lQNkIcB7/rdW+F33fbmp4jYze3G6J5n5WSY1a+OeN2Wm3NvMOj4D4+QJzmZ7lWRsMuXkX60w= 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 1668607921092786.742620497605; Wed, 16 Nov 2022 06:12:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ55-0001DP-1P; Wed, 16 Nov 2022 09:07:59 -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 1ovJ4z-0000uD-Bc for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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 1ovJ4t-0006BQ-3n for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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-611-tcVJnZaUPq6cFx4BOy1jSQ-1; Wed, 16 Nov 2022 09:07:41 -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 23A6086F13D; Wed, 16 Nov 2022 14:07:40 +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 85B56C1908A; Wed, 16 Nov 2022 14:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607666; 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=OwLDLnzEP3/wR4BUpGqG03oyOcX+DzKDBTWtcaqpOzE=; b=gyXoe7MYXKhNHGuLkE2QqS9mc81KWcjpjtrTKlEqaBmMfuOk6NpYJgxIRhXQZB+Tj9war1 Sd5e14CcixJfE9rmtfYh6NHtd8SHUhfiOuHksL99f8ZpxCReFp03xwYiKUCRp2Jr6rByDv o00mfDAoPc0U7EmDTt2X0rLqZGPBzhc= X-MC-Unique: tcVJnZaUPq6cFx4BOy1jSQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 09/15] block-coroutine-wrapper: support void functions Date: Wed, 16 Nov 2022 09:07:24 -0500 Message-Id: <20221116140730.3056048-10-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607922399100001 Content-Type: text/plain; charset="utf-8" Just omit the various 'return' when the return type is void. Signed-off-by: Emanuele Giuseppe Esposito --- scripts/block-coroutine-wrapper.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py index 05267761f0..8d7aa5d7f4 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -115,7 +115,7 @@ def create_g_c_w(func: FuncDecl) -> str: {func.return_type} {func.name}({ func.gen_list('{decl}') }) {{ if (qemu_in_coroutine()) {{ - return {name}({ func.gen_list('{name}') }); + {func.co_ret}{name}({ func.gen_list('{name}') }); }} else {{ {struct_name} s =3D {{ .poll_state.bs =3D {func.bs}, @@ -127,7 +127,7 @@ def create_g_c_w(func: FuncDecl) -> str: s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); =20 bdrv_poll_co(&s.poll_state); - return s.ret; + {func.ret} }} }}""" =20 @@ -150,7 +150,7 @@ def create_coroutine_only(func: FuncDecl) -> str: s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); =20 bdrv_poll_co(&s.poll_state); - return s.ret; + {func.ret} }}""" =20 =20 @@ -168,6 +168,15 @@ def gen_wrapper(func: FuncDecl) -> str: graph_lock=3D' bdrv_graph_co_rdlock();' graph_unlock=3D' bdrv_graph_co_rdunlock();' =20 + func.get_result =3D 's->ret =3D ' + func.ret =3D 'return s.ret;' + func.co_ret =3D 'return ' + func.return_field =3D func.return_type + " ret;" + if func.return_type =3D=3D 'void': + func.get_result =3D '' + func.ret =3D '' + func.co_ret =3D '' + func.return_field =3D '' =20 t =3D func.args[0].type if t =3D=3D 'BlockDriverState *': @@ -193,7 +202,7 @@ def gen_wrapper(func: FuncDecl) -> str: =20 typedef struct {struct_name} {{ BdrvPollCo poll_state; - {func.return_type} ret; + {func.return_field} { func.gen_block(' {decl};') } }} {struct_name}; =20 @@ -202,7 +211,7 @@ def gen_wrapper(func: FuncDecl) -> str: {struct_name} *s =3D opaque; =20 {graph_lock} - s->ret =3D {name}({ func.gen_list('s->{name}') }); + {func.get_result}{name}({ func.gen_list('s->{name}') }); {graph_unlock} s->poll_state.in_progress =3D false; =20 --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607982; cv=none; d=zohomail.com; s=zohoarc; b=MuMi1b0uy5mvXngriER229acUibbvNF+wl4/HEqFn/NhXNoluRnOnQcT68mEgdY9Tkclq5NMsX9DYx8BYp01IyUQCbwzmOdUzQ0q4TyvVigQGcYEhfrbt2/Vi7zo8oW7KgwOQ6MXDg+jVAPGXmadMaOJedYg2DvTiLdKNeDBPi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607982; 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=k1Mhe59cZBIrC6wBos2WnPNqvOkMJGGwmExzv0mvbrI=; b=M2y3ZvUWWt+nDAKssH4nX95LRwH41A2EAwirsAuEZsiOxZmPK4UdctDp8d6zhMJoDlTYcnWHfo0uUz7dzQcgt7/N4xiVVKUqlh57GbRycf6PHmySmley3qj0XhhVTRJx/uCTmQrOhdL4AMgjh9C72sWWmKerlBe3jC7g9G4Rdvk= 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 1668607982691829.5088759404243; Wed, 16 Nov 2022 06:13:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ56-0001GK-8j; Wed, 16 Nov 2022 09:08:00 -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 1ovJ4z-0000uE-EB for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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 1ovJ4s-0006BK-R5 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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-640-mMQNCoqFN_GL4JdnT91jOw-1; Wed, 16 Nov 2022 09:07:41 -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 C3DD48582B9; Wed, 16 Nov 2022 14:07:40 +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 2D319C2C7D9; Wed, 16 Nov 2022 14:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607666; 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=k1Mhe59cZBIrC6wBos2WnPNqvOkMJGGwmExzv0mvbrI=; b=X5958vpjEfLLnitAtBdSVgsUZ9RLe+F5KP+IhTwHRQg9UQ/w5j4t3GzXDAzK8BDUXtGrDu xepTeq3K78aIu6QSAPdCBSzV0GnM00FyxH6kbu8H2Q/HpSbN54AmuOK/AQp82+Mg3Ed8Pb 6h0FabDPuJ/irAkZBpfyp6qEViXYR6s= X-MC-Unique: mMQNCoqFN_GL4JdnT91jOw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 10/15] block: convert bdrv_eject in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:25 -0500 Message-Id: <20221116140730.3056048-11-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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=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: 1668607985580100006 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_eject is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. The only caller of this function is blk_eject, therefore make blk_eject a generated_co_wrapper_simple, so that it always creates a new coroutine, and then make bdrv_eject coroutine_fn. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 3 ++- block/block-backend.c | 5 +++-- block/copy-on-read.c | 2 +- block/filter-compress.c | 2 +- block/raw-format.c | 2 +- include/block/block-io.h | 3 ++- include/block/block_int-common.h | 2 +- include/sysemu/block-backend-io.h | 4 +++- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 4205735308..ffbb8c602f 100644 --- a/block.c +++ b/block.c @@ -6802,10 +6802,11 @@ bool coroutine_fn bdrv_co_is_inserted(BlockDriverSt= ate *bs) /** * If eject_flag is TRUE, eject the media. Otherwise, close the tray */ -void bdrv_eject(BlockDriverState *bs, bool eject_flag) +void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (drv && drv->bdrv_eject) { drv->bdrv_eject(bs, eject_flag); diff --git a/block/block-backend.c b/block/block-backend.c index 9a500fdde3..308dd2070a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2019,14 +2019,15 @@ void blk_lock_medium(BlockBackend *blk, bool locked) } } =20 -void blk_eject(BlockBackend *blk, bool eject_flag) +void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag) { BlockDriverState *bs =3D blk_bs(blk); char *id; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (bs) { - bdrv_eject(bs, eject_flag); + bdrv_co_eject(bs, eject_flag); } =20 /* Whether or not we ejected on the backend, diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 74f7727a02..76f884a6ae 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -218,7 +218,7 @@ static int coroutine_fn cor_co_pwritev_compressed(Block= DriverState *bs, =20 static void cor_eject(BlockDriverState *bs, bool eject_flag) { - bdrv_eject(bs->file->bs, eject_flag); + bdrv_co_eject(bs->file->bs, eject_flag); } =20 =20 diff --git a/block/filter-compress.c b/block/filter-compress.c index 305716c86c..571e4684dd 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -118,7 +118,7 @@ static void compress_refresh_limits(BlockDriverState *b= s, Error **errp) =20 static void compress_eject(BlockDriverState *bs, bool eject_flag) { - bdrv_eject(bs->file->bs, eject_flag); + bdrv_co_eject(bs->file->bs, eject_flag); } =20 =20 diff --git a/block/raw-format.c b/block/raw-format.c index 4773bf9cda..9b23cf17bb 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -405,7 +405,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverStat= e *bs, int64_t offset, =20 static void raw_eject(BlockDriverState *bs, bool eject_flag) { - bdrv_eject(bs->file->bs, eject_flag); + bdrv_co_eject(bs->file->bs, eject_flag); } =20 static void raw_lock_medium(BlockDriverState *bs, bool locked) diff --git a/include/block/block-io.h b/include/block/block-io.h index 3432e6ad3e..204adeb701 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -125,7 +125,8 @@ bool coroutine_fn bdrv_co_is_inserted(BlockDriverState = *bs); bool generated_co_wrapper_simple bdrv_is_inserted(BlockDriverState *bs); =20 void bdrv_lock_medium(BlockDriverState *bs, bool locked); -void bdrv_eject(BlockDriverState *bs, bool eject_flag); +void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag); + const char *bdrv_get_format_name(BlockDriverState *bs); =20 bool bdrv_supports_compressed_writes(BlockDriverState *bs); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 4cad48b2ad..d01b3d44f5 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -761,7 +761,7 @@ struct BlockDriver { =20 /* removable device specific. Called with graph rdlock held. */ bool coroutine_fn (*bdrv_is_inserted)(BlockDriverState *bs); - void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); + void coroutine_fn (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); =20 /* to control generic scsi devices. Called with graph rdlock taken. */ diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index bf88f7699e..cc706c03d8 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -59,7 +59,9 @@ bool generated_co_wrapper blk_is_inserted(BlockBackend *b= lk); =20 bool blk_is_available(BlockBackend *blk); void blk_lock_medium(BlockBackend *blk, bool locked); -void blk_eject(BlockBackend *blk, bool eject_flag); + +void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag); +void generated_co_wrapper_simple blk_eject(BlockBackend *blk, bool eject_f= lag); =20 int64_t coroutine_fn blk_co_getlength(BlockBackend *blk); int64_t generated_co_wrapper_blk blk_getlength(BlockBackend *blk); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668608035; cv=none; d=zohomail.com; s=zohoarc; b=U52ZFqjK/xgGev80XWmq16d4wZJJZyQZlqSocEyUND23odY4KiJmr7SWCIZXXDg7UEanthewEsC2WV0Ab82l7anUr7/scs2zUjvsQq8FnjVio+OyeIpc/N445m+S6RTzBezAvrS03PnyzMo9wq1tS/fLH6qmo2iG4q9ENQQ1BRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668608035; 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=lm915XGX6fwpz7RDWuUK1Yqycg+7SVAnupnJpMzlUx8=; b=MtSiZAataZk0KR76qvqszbzcT4I0W1485laEdEihZAkLoKlNYkk9f7UPusQeHRmZzkkLHf1NPCOBnPs69oUHbWOlf27bTQ4x6FSLJDRBW6dkc1Oc5DzEp5u6PQuIdN/2Lp8nQp1pE3S3jt5BwVF2a+bmg2gFMDZxJkC223NaM04= 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 1668608035888943.1833230963408; Wed, 16 Nov 2022 06:13:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ54-0001CK-Bz; Wed, 16 Nov 2022 09:07:58 -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 1ovJ4z-0000uC-BE for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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 1ovJ4s-0006AC-FU for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:53 -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-160-q5oWUr1GMGeIYJb2Oziz6w-1; Wed, 16 Nov 2022 09:07:42 -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 6853D3C10148; Wed, 16 Nov 2022 14:07:41 +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 CAA24C2C8D2; Wed, 16 Nov 2022 14:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607664; 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=lm915XGX6fwpz7RDWuUK1Yqycg+7SVAnupnJpMzlUx8=; b=cWm1hVToNC06CnGnJc9iTWwPJYJl+vrBM/MuOxdFOxXKkp8bxEYkTbGT6vm9uW/qsSN2Ga zdCGWUzbt9qOk8UH/UukaWLRs0cR+KrR+SxSlZkQSXaSVKzRwiTL2jyGglHuk2+nGUqNFC FllM165GPWogRmOy6+zYx6F+5UgqIHM= X-MC-Unique: q5oWUr1GMGeIYJb2Oziz6w-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 11/15] block: convert bdrv_lock_medium in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:26 -0500 Message-Id: <20221116140730.3056048-12-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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=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: 1668608037103100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_lock_medium is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. The only caller of this function is blk_lock_medium, therefore make blk_lock_medium a generated_co_wrapper_simple, so that it always creates a new coroutine, and then make bdrv_lock_medium coroutine_fn. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 3 ++- block/block-backend.c | 5 +++-- block/copy-on-read.c | 2 +- block/filter-compress.c | 2 +- block/raw-format.c | 2 +- include/block/block-io.h | 2 +- include/block/block_int-common.h | 2 +- include/sysemu/block-backend-io.h | 5 ++++- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index ffbb8c602f..afc5735b82 100644 --- a/block.c +++ b/block.c @@ -6817,10 +6817,11 @@ void coroutine_fn bdrv_co_eject(BlockDriverState *b= s, bool eject_flag) * Lock or unlock the media (if it is locked, the user won't be able * to eject it manually). */ -void bdrv_lock_medium(BlockDriverState *bs, bool locked) +void coroutine_fn bdrv_co_lock_medium(BlockDriverState *bs, bool locked) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); trace_bdrv_lock_medium(bs, locked); =20 if (drv && drv->bdrv_lock_medium) { diff --git a/block/block-backend.c b/block/block-backend.c index 308dd2070a..75e2f2124f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2009,13 +2009,14 @@ bool blk_is_available(BlockBackend *blk) return blk_is_inserted(blk) && !blk_dev_is_tray_open(blk); } =20 -void blk_lock_medium(BlockBackend *blk, bool locked) +void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked) { BlockDriverState *bs =3D blk_bs(blk); IO_CODE(); + assert_bdrv_graph_readable(); =20 if (bs) { - bdrv_lock_medium(bs, locked); + bdrv_co_lock_medium(bs, locked); } } =20 diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 76f884a6ae..ccc767f37b 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -224,7 +224,7 @@ static void cor_eject(BlockDriverState *bs, bool eject_= flag) =20 static void cor_lock_medium(BlockDriverState *bs, bool locked) { - bdrv_lock_medium(bs->file->bs, locked); + bdrv_co_lock_medium(bs->file->bs, locked); } =20 =20 diff --git a/block/filter-compress.c b/block/filter-compress.c index 571e4684dd..e10312c225 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -124,7 +124,7 @@ static void compress_eject(BlockDriverState *bs, bool e= ject_flag) =20 static void compress_lock_medium(BlockDriverState *bs, bool locked) { - bdrv_lock_medium(bs->file->bs, locked); + bdrv_co_lock_medium(bs->file->bs, locked); } =20 =20 diff --git a/block/raw-format.c b/block/raw-format.c index 9b23cf17bb..96a9b33384 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -410,7 +410,7 @@ static void raw_eject(BlockDriverState *bs, bool eject_= flag) =20 static void raw_lock_medium(BlockDriverState *bs, bool locked) { - bdrv_lock_medium(bs->file->bs, locked); + bdrv_co_lock_medium(bs->file->bs, locked); } =20 static int coroutine_fn raw_co_ioctl(BlockDriverState *bs, diff --git a/include/block/block-io.h b/include/block/block-io.h index 204adeb701..497580fc28 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -124,7 +124,7 @@ int bdrv_get_flags(BlockDriverState *bs); bool coroutine_fn bdrv_co_is_inserted(BlockDriverState *bs); bool generated_co_wrapper_simple bdrv_is_inserted(BlockDriverState *bs); =20 -void bdrv_lock_medium(BlockDriverState *bs, bool locked); +void coroutine_fn bdrv_co_lock_medium(BlockDriverState *bs, bool locked); void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag); =20 const char *bdrv_get_format_name(BlockDriverState *bs); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index d01b3d44f5..3e1eba518c 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -762,7 +762,7 @@ struct BlockDriver { /* removable device specific. Called with graph rdlock held. */ bool coroutine_fn (*bdrv_is_inserted)(BlockDriverState *bs); void coroutine_fn (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); - void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); + void coroutine_fn (*bdrv_lock_medium)(BlockDriverState *bs, bool locke= d); =20 /* to control generic scsi devices. Called with graph rdlock taken. */ BlockAIOCB *coroutine_fn (*bdrv_aio_ioctl)(BlockDriverState *bs, diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index cc706c03d8..dd8566ee69 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -58,7 +58,10 @@ bool coroutine_fn blk_co_is_inserted(BlockBackend *blk); bool generated_co_wrapper blk_is_inserted(BlockBackend *blk); =20 bool blk_is_available(BlockBackend *blk); -void blk_lock_medium(BlockBackend *blk, bool locked); + +void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked); +void generated_co_wrapper_simple blk_lock_medium(BlockBackend *blk, + bool locked); =20 void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag); void generated_co_wrapper_simple blk_eject(BlockBackend *blk, bool eject_f= lag); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607692; cv=none; d=zohomail.com; s=zohoarc; b=PUUUlFfsWhLrCC5sxm1dNIJsYRuGuKn/g7skzeUtJTxgmf2Vm4kI4qM1RscOxk5Kuu7Ih7UHqSNweJmkdh9/pt82OK9Jsj04gelbx+imeIyc4RwOsh3un3F6usVfoiUxWVnZUM3BU5yBaebVf10PpQp7oZmBFVwRng96rHPC+hU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607692; 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=ndBxEipnIcXw6yOeHrUZcMyNT520NaR+GbAsbSQvqBg=; b=VSzbbJ2JfKcCCVUx1h2kq35qOmb/hY+Y9GTEi7LbbfFmgePpjekYy0Jg8Gn8mg5pYAPbMbiRTJqIUJ9UP/LPN8w1BmNjVfCh7dDpvzQ4N20lT5t3Xsh1/7jkKP1PwB8LpGzp7ko0m+Q08lxUUb5uIwtcPQtWf5jYqaPFx5rJ2tY= 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 1668607692198559.4299870007299; Wed, 16 Nov 2022 06:08:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ58-0001My-5J; Wed, 16 Nov 2022 09:08:02 -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 1ovJ50-0000wm-Au for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:55 -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 1ovJ4t-0006Br-PE for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:54 -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-216-LEH2WPoiMxOgXUznwvuY3A-1; Wed, 16 Nov 2022 09:07:44 -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 0F0E63C1014C; Wed, 16 Nov 2022 14:07:42 +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 7200CC2C8CC; Wed, 16 Nov 2022 14:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607667; 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=ndBxEipnIcXw6yOeHrUZcMyNT520NaR+GbAsbSQvqBg=; b=L4VG2N2lv03WR87hgHfW8PPppbfrvSHEtmIt3BUmDuDqrC05UG7wW5HypTewp2XrZhY72a rDgWs9WZnVoy3LoGDpm8kXHPrqaxJOlc/UydHHGVEjhdovLYoRtnp+KQO6DgGO8vgUJq74 2gqU/vK9P+K+AFm3hBgD5ECmSYodLxE= X-MC-Unique: LEH2WPoiMxOgXUznwvuY3A-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 12/15] block: convert bdrv_debug_event in generated_co_wrapper Date: Wed, 16 Nov 2022 09:07:27 -0500 Message-Id: <20221116140730.3056048-13-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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: 1668607694117100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_debug_event is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. Therefore use generated_co_wrapper to automatically create a wrapper with the same name. Unfortunately we cannot use a generated_co_wrapper_simple, because the function is called by mixed functions that run both in coroutine and non-coroutine context (for example blkdebug_open). Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 4 +++- block/io.c | 22 +++++++++++----------- include/block/block-io.h | 7 +++++-- include/block/block_int-common.h | 4 +++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index afc5735b82..a2e3550d5c 100644 --- a/block.c +++ b/block.c @@ -6331,9 +6331,11 @@ BlockStatsSpecific *bdrv_get_specific_stats(BlockDri= verState *bs) return drv->bdrv_get_specific_stats(bs); } =20 -void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event) +void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent = event) { IO_CODE(); + assert_bdrv_graph_readable(); + if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { return; } diff --git a/block/io.c b/block/io.c index 88da9470c3..11d2c5dcde 100644 --- a/block/io.c +++ b/block/io.c @@ -1227,7 +1227,7 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, goto err; } =20 - bdrv_debug_event(bs, BLKDBG_COR_WRITE); + bdrv_co_debug_event(bs, BLKDBG_COR_WRITE); if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, pnum)) { /* FIXME: Should we (perhaps conditionally) be setting @@ -1472,10 +1472,10 @@ static coroutine_fn int bdrv_padding_rmw_read(BdrvC= hild *child, qemu_iovec_init_buf(&local_qiov, pad->buf, bytes); =20 if (pad->head) { - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); } if (pad->merge_reads && pad->tail) { - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); } ret =3D bdrv_aligned_preadv(child, req, req->overlap_offset, bytes, align, &local_qiov, 0, 0); @@ -1483,10 +1483,10 @@ static coroutine_fn int bdrv_padding_rmw_read(BdrvC= hild *child, return ret; } if (pad->head) { - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); } if (pad->merge_reads && pad->tail) { - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); } =20 if (pad->merge_reads) { @@ -1497,7 +1497,7 @@ static coroutine_fn int bdrv_padding_rmw_read(BdrvChi= ld *child, if (pad->tail) { qemu_iovec_init_buf(&local_qiov, pad->tail_buf, align); =20 - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); ret =3D bdrv_aligned_preadv( child, req, req->overlap_offset + req->overlap_bytes - align, @@ -1505,7 +1505,7 @@ static coroutine_fn int bdrv_padding_rmw_read(BdrvChi= ld *child, if (ret < 0) { return ret; } - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); } =20 zero_mem: @@ -1908,16 +1908,16 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvCh= ild *child, if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { - bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_ZERO); ret =3D bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags); } else if (flags & BDRV_REQ_WRITE_COMPRESSED) { ret =3D bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov, qiov_offset); } else if (bytes <=3D max_transfer) { - bdrv_debug_event(bs, BLKDBG_PWRITEV); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV); ret =3D bdrv_driver_pwritev(bs, offset, bytes, qiov, qiov_offset, = flags); } else { - bdrv_debug_event(bs, BLKDBG_PWRITEV); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV); while (bytes_remaining) { int num =3D MIN(bytes_remaining, max_transfer); int local_flags =3D flags; @@ -1940,7 +1940,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, bytes_remaining -=3D num; } } - bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE); + bdrv_co_debug_event(bs, BLKDBG_PWRITEV_DONE); =20 if (ret >=3D 0) { ret =3D 0; diff --git a/include/block/block-io.h b/include/block/block-io.h index 497580fc28..176e3cc734 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -170,12 +170,15 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size= _t size); void bdrv_enable_copy_on_read(BlockDriverState *bs); void bdrv_disable_copy_on_read(BlockDriverState *bs); =20 -void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event); +void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, + BlkdebugEvent event); +void generated_co_wrapper bdrv_debug_event(BlockDriverState *bs, + BlkdebugEvent event); =20 #define BLKDBG_EVENT(child, evt) \ do { \ if (child) { \ - bdrv_debug_event(child->bs, evt); \ + bdrv_co_debug_event(child->bs, evt); \ } \ } while (0) =20 diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 3e1eba518c..b509855c19 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -781,7 +781,9 @@ struct BlockDriver { BdrvCheckResult *result, BdrvCheckMode fix); =20 - void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); + /* Called with graph rdlock taken. */ + void coroutine_fn (*bdrv_debug_event)(BlockDriverState *bs, + BlkdebugEvent event); =20 /* io queue for linux-aio */ void (*bdrv_io_plug)(BlockDriverState *bs); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607789; cv=none; d=zohomail.com; s=zohoarc; b=O7Zd1nP5UNFqC7N7i5x5WOhSIZRfJkqAFzIudxO8TYP+PIvvyJTIm5/o6EKOS16PyLeqUOEh9CgLuemNMudsPrSTt9s3Mn08hCcrLAByIrRZ8XT4fnSh1a5rcl+BMaRBi4jgTO69J3EsOX8eCcjPgPE5Xj51b+F1E3AXGQUmcPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607789; 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=OJWhXn7L5fRW6faD6Zr3DmPk0qnapltpuK9piwE3ENI=; b=R8O8ymXTDxRw42I/Pp1CV6m2/i3ED93aqLtaFrmqiV84NGoEQWHfXCgSeZ9GBFyyuvSsGU94UCdMpt8BotvFhKDWHn2j1Q9G/HFz4Jn71O76oRBImRGPbxDF+Y8r8SnSQvSFOBmMxd7YoJ19xyHctgF/33jYcY4Qk7GrEcqSLbM= 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 1668607789785704.4556085636568; Wed, 16 Nov 2022 06:09:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ57-0001JT-5n; Wed, 16 Nov 2022 09:08:01 -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 1ovJ52-00011A-0B for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:57 -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 1ovJ4v-0006Bx-NZ for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:55 -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-365-K9iJxkp9NXavBvqxiFJSbg-1; Wed, 16 Nov 2022 09:07:43 -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 AADA78027F5; Wed, 16 Nov 2022 14:07:42 +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 18803C2C8C5; Wed, 16 Nov 2022 14:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607667; 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=OJWhXn7L5fRW6faD6Zr3DmPk0qnapltpuK9piwE3ENI=; b=bAMOfEEs82mJUNnZ7utiiG98X/DTgi4tyz6cOPQDM0Rn7hF0tKznt1PtHd1EtOV/sucpkY lzqMVp96WVTLspZjaEh6qLHVbpwXTPagdIf9QPb9JmihsgM5e9GHVeMmB+VYAp896UjoZV 1ujq3zN3xie6mzXQNy/+6e3SEIrWXSs= X-MC-Unique: K9iJxkp9NXavBvqxiFJSbg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 13/15] block: convert bdrv_io_plug in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:28 -0500 Message-Id: <20221116140730.3056048-14-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607791042100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_io_plug is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. The only caller of this function is blk_plug, therefore make blk_plug a generated_co_wrapper_simple, so that it always creates a new coroutine, and then make bdrv_plug coroutine_fn. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 5 +++-- block/io.c | 5 +++-- include/block/block-io.h | 3 ++- include/block/block_int-common.h | 4 ++-- include/sysemu/block-backend-io.h | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 75e2f2124f..826a936beb 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2329,13 +2329,14 @@ void blk_add_insert_bs_notifier(BlockBackend *blk, = Notifier *notify) notifier_list_add(&blk->insert_bs_notifiers, notify); } =20 -void blk_io_plug(BlockBackend *blk) +void coroutine_fn blk_co_io_plug(BlockBackend *blk) { BlockDriverState *bs =3D blk_bs(blk); IO_CODE(); + assert_bdrv_graph_readable(); =20 if (bs) { - bdrv_io_plug(bs); + bdrv_co_io_plug(bs); } } =20 diff --git a/block/io.c b/block/io.c index 11d2c5dcde..d3b8c1e4b2 100644 --- a/block/io.c +++ b/block/io.c @@ -3068,13 +3068,14 @@ void *qemu_try_blockalign0(BlockDriverState *bs, si= ze_t size) return mem; } =20 -void bdrv_io_plug(BlockDriverState *bs) +void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs) { BdrvChild *child; IO_CODE(); + assert_bdrv_graph_readable(); =20 QLIST_FOREACH(child, &bs->children, next) { - bdrv_io_plug(child->bs); + bdrv_co_io_plug(child->bs); } =20 if (qatomic_fetch_inc(&bs->io_plugged) =3D=3D 0) { diff --git a/include/block/block-io.h b/include/block/block-io.h index 176e3cc734..a045643b26 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -215,7 +215,8 @@ void bdrv_coroutine_enter(BlockDriverState *bs, Corouti= ne *co); =20 AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c); =20 -void bdrv_io_plug(BlockDriverState *bs); +void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs); + void bdrv_io_unplug(BlockDriverState *bs); =20 bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index b509855c19..ed96bc3241 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -785,8 +785,8 @@ struct BlockDriver { void coroutine_fn (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); =20 - /* io queue for linux-aio */ - void (*bdrv_io_plug)(BlockDriverState *bs); + /* io queue for linux-aio. Called with graph rdlock taken. */ + void coroutine_fn (*bdrv_io_plug)(BlockDriverState *bs); void (*bdrv_io_unplug)(BlockDriverState *bs); =20 /** diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index dd8566ee69..703fcc3ac5 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -87,7 +87,9 @@ void blk_iostatus_set_err(BlockBackend *blk, int error); int blk_get_max_iov(BlockBackend *blk); int blk_get_max_hw_iov(BlockBackend *blk); =20 -void blk_io_plug(BlockBackend *blk); +void coroutine_fn blk_co_io_plug(BlockBackend *blk); +void generated_co_wrapper_simple blk_io_plug(BlockBackend *blk); + void blk_io_unplug(BlockBackend *blk); AioContext *blk_get_aio_context(BlockBackend *blk); BlockAcctStats *blk_get_stats(BlockBackend *blk); --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607989; cv=none; d=zohomail.com; s=zohoarc; b=hJAPNvptphRkDxkVAi3ivqKn4XvfnqKJvbW3HN6+Hd8c1aO2MSP7X+D+JqX4+7M40n1fEtqRFNUlQlzqhxMihtIoe3k+RgHnLDjOqK2x9xqZdRaoHsJofQkaYaUj6n33zelD7co74YHoCXJIzQdDFyf004U7pxsmUcxghCDIfmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607989; 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=LShO/uGsC8MvfXvuAy3Z4R8eneqVZb89nHc5ckNve1A=; b=TbUOxX4aIkxK0h/0qealfd2hYKXeM2bHUhPDcDuzCBCKp7N10KhNr50spyxcIO5luUte+EfTEYM338RYOvZ8cp2lSQ2gVTmCUQJjMQ8u+oZHxtPW6xWaDa63DoQoQBIeusSJc0mheSZICg3tE1ftjYtXG51/mmYHIszoDHLAfy0= 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 1668607989381196.19153911904198; Wed, 16 Nov 2022 06:13:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ5B-0001Yx-8k; Wed, 16 Nov 2022 09:08:05 -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 1ovJ55-0001Fb-Sq for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:59 -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 1ovJ51-0006Ez-VD for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:59 -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-654-wuejGfBGP4mN9Qsk90D3tA-1; Wed, 16 Nov 2022 09:07:44 -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 521FA3810D36; Wed, 16 Nov 2022 14:07:43 +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 B4941C2C7E6; Wed, 16 Nov 2022 14:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607674; 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=LShO/uGsC8MvfXvuAy3Z4R8eneqVZb89nHc5ckNve1A=; b=MhVWa+8PIDksjMwLCEbKIgZXk9q8+fIzrpIa8wY/Gw+fZNNvVPdg07l8OHQq9E9ADNO1OV uIq0V1pydNbkPZqVFE3LcgpUBjk4QJa9JL5zxYAz6x167g2jkkjo4PNxkPD9d8TUfJGZSH OVKSWTkuZfukZQmwP8ZIIZUKPtXkIco= X-MC-Unique: wuejGfBGP4mN9Qsk90D3tA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 14/15] block: convert bdrv_io_unplug in generated_co_wrapper_simple Date: Wed, 16 Nov 2022 09:07:29 -0500 Message-Id: <20221116140730.3056048-15-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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=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: 1668607990635100001 Content-Type: text/plain; charset="utf-8" BlockDriver->bdrv_io_unplug is categorized as IO callback, and it currently doesn't run in a coroutine. This makes very difficult to add the graph rdlock, since the callback traverses the block nodes graph. The only caller of this function is blk_unplug, therefore make blk_unplug a generated_co_wrapper_simple, so that it always creates a new coroutine, and then make bdrv_unplug coroutine_fn. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 5 +++-- block/io.c | 5 +++-- include/block/block-io.h | 3 +-- include/block/block_int-common.h | 2 +- include/sysemu/block-backend-io.h | 4 +++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 826a936beb..3b10e35ea4 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2340,13 +2340,14 @@ void coroutine_fn blk_co_io_plug(BlockBackend *blk) } } =20 -void blk_io_unplug(BlockBackend *blk) +void coroutine_fn blk_co_io_unplug(BlockBackend *blk) { BlockDriverState *bs =3D blk_bs(blk); IO_CODE(); + assert_bdrv_graph_readable(); =20 if (bs) { - bdrv_io_unplug(bs); + bdrv_co_io_unplug(bs); } } =20 diff --git a/block/io.c b/block/io.c index d3b8c1e4b2..48a94dd384 100644 --- a/block/io.c +++ b/block/io.c @@ -3086,10 +3086,11 @@ void coroutine_fn bdrv_co_io_plug(BlockDriverState = *bs) } } =20 -void bdrv_io_unplug(BlockDriverState *bs) +void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs) { BdrvChild *child; IO_CODE(); + assert_bdrv_graph_readable(); =20 assert(bs->io_plugged); if (qatomic_fetch_dec(&bs->io_plugged) =3D=3D 1) { @@ -3100,7 +3101,7 @@ void bdrv_io_unplug(BlockDriverState *bs) } =20 QLIST_FOREACH(child, &bs->children, next) { - bdrv_io_unplug(child->bs); + bdrv_co_io_unplug(child->bs); } } =20 diff --git a/include/block/block-io.h b/include/block/block-io.h index a045643b26..f93357681a 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -216,8 +216,7 @@ void bdrv_coroutine_enter(BlockDriverState *bs, Corouti= ne *co); AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c); =20 void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs); - -void bdrv_io_unplug(BlockDriverState *bs); +void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs); =20 bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index ed96bc3241..3ab3fa45a2 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -787,7 +787,7 @@ struct BlockDriver { =20 /* io queue for linux-aio. Called with graph rdlock taken. */ void coroutine_fn (*bdrv_io_plug)(BlockDriverState *bs); - void (*bdrv_io_unplug)(BlockDriverState *bs); + void coroutine_fn (*bdrv_io_unplug)(BlockDriverState *bs); =20 /** * bdrv_drain_begin is called if implemented in the beginning of a diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 703fcc3ac5..c8df7320f7 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -90,7 +90,9 @@ int blk_get_max_hw_iov(BlockBackend *blk); void coroutine_fn blk_co_io_plug(BlockBackend *blk); void generated_co_wrapper_simple blk_io_plug(BlockBackend *blk); =20 -void blk_io_unplug(BlockBackend *blk); +void coroutine_fn blk_co_io_unplug(BlockBackend *blk); +void generated_co_wrapper_simple blk_io_unplug(BlockBackend *blk); + AioContext *blk_get_aio_context(BlockBackend *blk); BlockAcctStats *blk_get_stats(BlockBackend *blk); void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, --=20 2.31.1 From nobody Sat May 18 23:23:25 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=1668607921; cv=none; d=zohomail.com; s=zohoarc; b=aJAYa1g7Rfxuozg+n6vC+iKR+Wp3qJ3+Jm0ToCAiOTalDUN2TbjnZicDimddU0kqx+iDUI6FLYmmdX9iK3yzcpYcqHZ4i+OlFb6hqVvjppYX9fpRBWrfvKK4sOww1wsSmYPfGRqUxKNPLQleYNxkhsSMFUw/MNn3NzMIVxCTLSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607921; 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=CUOwUQCGpk0pB0B8trhGgXXbW++AvBNYGEwyBZaC+hw=; b=YDGefJAxhLDgQ4AM1w+JORyucUV810r6nuiQqutSmXgVUgIu0jw/FfbXhAt2eLQdC9Vnoc8rIl/DBWxM7tDrOHx+giYdSCBbyZZjifG1t/8AmPzLpPanIWm+tkqF36njprZZv8TX0iCKxmmSGd/LzvIQA5ohyW2A0+Pk3TPINU4= 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 16686079215471017.8031051829752; Wed, 16 Nov 2022 06:12:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJ5A-0001Ue-0g; Wed, 16 Nov 2022 09:08:04 -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 1ovJ52-00013y-Ua for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:56 -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 1ovJ4w-0006CZ-2e for qemu-devel@nongnu.org; Wed, 16 Nov 2022 09:07:56 -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-115-JNd5ZdPBN1i2rOgmBFmLOg-1; Wed, 16 Nov 2022 09:07:45 -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 0D3F186F12E; Wed, 16 Nov 2022 14:07:44 +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 6195DC2C8C5; Wed, 16 Nov 2022 14:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668607669; 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=CUOwUQCGpk0pB0B8trhGgXXbW++AvBNYGEwyBZaC+hw=; b=fK0ptFscfQwMq51K2Xh1yX1m7jDiEeWZ1QWMjifSCAxpUWG1XOsiPVhhtaSK8fcWq2t4aw QYgT7DMOWKgIVbjYvJLAEZjjAnadnP4VtDcCwOgKJwt/ytZf88xRR5BNB6lBuFHQo9fHJI vwsxCcJZKd+5Orh1O4vs3TT4AA55hkg= X-MC-Unique: JNd5ZdPBN1i2rOgmBFmLOg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Stefan Weil , Fam Zheng , Ronnie Sahlberg , Peter Lieven , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alberto Garcia , Ilya Dryomov , Wen Congyang , Xie Changlong , "Richard W.M. Jones" , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, integration@gluster.org, Emanuele Giuseppe Esposito Subject: [PATCH 15/15] block: rename newly converted BlockDriver IO coroutine functions Date: Wed, 16 Nov 2022 09:07:30 -0500 Message-Id: <20221116140730.3056048-16-eesposit@redhat.com> In-Reply-To: <20221116140730.3056048-1-eesposit@redhat.com> References: <20221116140730.3056048-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.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: 1668607922465100003 Content-Type: text/plain; charset="utf-8" Since these functions alwayas run in coroutine context, adjust their name to include "_co_", just like all other BlockDriver callbacks. No functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 32 ++++++++++----------- block/blkdebug.c | 4 +-- block/blkio.c | 6 ++-- block/blklogwrites.c | 2 +- block/blkreplay.c | 2 +- block/blkverify.c | 2 +- block/copy-on-read.c | 6 ++-- block/crypto.c | 4 +-- block/curl.c | 8 +++--- block/file-posix.c | 48 ++++++++++++++++---------------- block/file-win32.c | 8 +++--- block/filter-compress.c | 6 ++-- block/gluster.c | 16 +++++------ block/io.c | 16 +++++------ block/iscsi.c | 8 +++--- block/nbd.c | 6 ++-- block/nfs.c | 2 +- block/null.c | 8 +++--- block/nvme.c | 6 ++-- block/preallocate.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 6 ++-- block/qed.c | 4 +-- block/quorum.c | 2 +- block/raw-format.c | 8 +++--- block/rbd.c | 4 +-- block/replication.c | 2 +- block/ssh.c | 2 +- block/throttle.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 4 +-- block/vpc.c | 2 +- include/block/block_int-common.h | 27 +++++++++--------- 34 files changed, 131 insertions(+), 130 deletions(-) diff --git a/block.c b/block.c index a2e3550d5c..78b3e7fcd6 100644 --- a/block.c +++ b/block.c @@ -1055,13 +1055,13 @@ int coroutine_fn bdrv_co_refresh_total_sectors(Bloc= kDriverState *bs, return -ENOMEDIUM; } =20 - /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */ + /* Do not attempt drv->bdrv_co_getlength() on scsi-generic devices */ if (bdrv_is_sg(bs)) return 0; =20 /* query actual device if possible, otherwise just trust the hint */ - if (drv->bdrv_getlength) { - int64_t length =3D drv->bdrv_getlength(bs); + if (drv->bdrv_co_getlength) { + int64_t length =3D drv->bdrv_co_getlength(bs); if (length < 0) { return length; } @@ -5695,7 +5695,7 @@ exit: } =20 /** - * Implementation of BlockDriver.bdrv_get_allocated_file_size() that + * Implementation of BlockDriver.bdrv_co_get_allocated_file_size() that * sums the size of all data-bearing children. (This excludes backing * children.) */ @@ -5732,8 +5732,8 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(= BlockDriverState *bs) if (!drv) { return -ENOMEDIUM; } - if (drv->bdrv_get_allocated_file_size) { - return drv->bdrv_get_allocated_file_size(bs); + if (drv->bdrv_co_get_allocated_file_size) { + return drv->bdrv_co_get_allocated_file_size(bs); } =20 if (drv->bdrv_file_open) { @@ -6290,7 +6290,7 @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *b= s, BlockDriverInfo *bdi) if (!drv) { return -ENOMEDIUM; } - if (!drv->bdrv_get_info) { + if (!drv->bdrv_co_get_info) { BlockDriverState *filtered =3D bdrv_filter_bs(bs); if (filtered) { return bdrv_co_get_info(filtered, bdi); @@ -6298,7 +6298,7 @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *b= s, BlockDriverInfo *bdi) return -ENOTSUP; } memset(bdi, 0, sizeof(*bdi)); - ret =3D drv->bdrv_get_info(bs, bdi); + ret =3D drv->bdrv_co_get_info(bs, bdi); if (ret < 0) { return ret; } @@ -6336,11 +6336,11 @@ void coroutine_fn bdrv_co_debug_event(BlockDriverSt= ate *bs, BlkdebugEvent event) IO_CODE(); assert_bdrv_graph_readable(); =20 - if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { + if (!bs || !bs->drv || !bs->drv->bdrv_co_debug_event) { return; } =20 - bs->drv->bdrv_debug_event(bs, event); + bs->drv->bdrv_co_debug_event(bs, event); } =20 static BlockDriverState *bdrv_find_debug_node(BlockDriverState *bs) @@ -6790,8 +6790,8 @@ bool coroutine_fn bdrv_co_is_inserted(BlockDriverStat= e *bs) if (!drv) { return false; } - if (drv->bdrv_is_inserted) { - return drv->bdrv_is_inserted(bs); + if (drv->bdrv_co_is_inserted) { + return drv->bdrv_co_is_inserted(bs); } QLIST_FOREACH(child, &bs->children, next) { if (!bdrv_co_is_inserted(child->bs)) { @@ -6810,8 +6810,8 @@ void coroutine_fn bdrv_co_eject(BlockDriverState *bs,= bool eject_flag) IO_CODE(); assert_bdrv_graph_readable(); =20 - if (drv && drv->bdrv_eject) { - drv->bdrv_eject(bs, eject_flag); + if (drv && drv->bdrv_co_eject) { + drv->bdrv_co_eject(bs, eject_flag); } } =20 @@ -6826,8 +6826,8 @@ void coroutine_fn bdrv_co_lock_medium(BlockDriverStat= e *bs, bool locked) assert_bdrv_graph_readable(); trace_bdrv_lock_medium(bs, locked); =20 - if (drv && drv->bdrv_lock_medium) { - drv->bdrv_lock_medium(bs, locked); + if (drv && drv->bdrv_co_lock_medium) { + drv->bdrv_co_lock_medium(bs, locked); } } =20 diff --git a/block/blkdebug.c b/block/blkdebug.c index 4265ca125e..1b85e84b7a 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -1076,7 +1076,7 @@ static BlockDriver bdrv_blkdebug =3D { .bdrv_reopen_prepare =3D blkdebug_reopen_prepare, .bdrv_child_perm =3D blkdebug_child_perm, =20 - .bdrv_getlength =3D blkdebug_getlength, + .bdrv_co_getlength =3D blkdebug_getlength, .bdrv_refresh_filename =3D blkdebug_refresh_filename, .bdrv_refresh_limits =3D blkdebug_refresh_limits, =20 @@ -1087,7 +1087,7 @@ static BlockDriver bdrv_blkdebug =3D { .bdrv_co_pdiscard =3D blkdebug_co_pdiscard, .bdrv_co_block_status =3D blkdebug_co_block_status, =20 - .bdrv_debug_event =3D blkdebug_debug_event, + .bdrv_co_debug_event =3D blkdebug_debug_event, .bdrv_debug_breakpoint =3D blkdebug_debug_breakpoint, .bdrv_debug_remove_breakpoint =3D blkdebug_debug_remove_breakpoint, diff --git a/block/blkio.c b/block/blkio.c index 5eae3adfaf..669b940ce6 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -996,9 +996,9 @@ static void blkio_refresh_limits(BlockDriverState *bs, = Error **errp) .instance_size =3D sizeof(BDRVBlkioState), \ .bdrv_file_open =3D blkio_file_open, \ .bdrv_close =3D blkio_close, \ - .bdrv_getlength =3D blkio_getlength, \ + .bdrv_co_getlength =3D blkio_getlength, \ .bdrv_co_truncate =3D blkio_truncate, \ - .bdrv_get_info =3D blkio_get_info, \ + .bdrv_co_get_info =3D blkio_get_info, \ .bdrv_attach_aio_context =3D blkio_attach_aio_context, \ .bdrv_detach_aio_context =3D blkio_detach_aio_context, \ .bdrv_co_pdiscard =3D blkio_co_pdiscard, \ @@ -1006,7 +1006,7 @@ static void blkio_refresh_limits(BlockDriverState *bs= , Error **errp) .bdrv_co_pwritev =3D blkio_co_pwritev, \ .bdrv_co_flush_to_disk =3D blkio_co_flush, \ .bdrv_co_pwrite_zeroes =3D blkio_co_pwrite_zeroes, \ - .bdrv_io_unplug =3D blkio_io_unplug, \ + .bdrv_co_io_unplug =3D blkio_io_unplug, \ .bdrv_refresh_limits =3D blkio_refresh_limits, \ .bdrv_register_buf =3D blkio_register_buf, \ .bdrv_unregister_buf =3D blkio_unregister_buf, \ diff --git a/block/blklogwrites.c b/block/blklogwrites.c index cef9efe55d..72ff8fb6a8 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -497,7 +497,7 @@ static BlockDriver bdrv_blk_log_writes =3D { =20 .bdrv_open =3D blk_log_writes_open, .bdrv_close =3D blk_log_writes_close, - .bdrv_getlength =3D blk_log_writes_getlength, + .bdrv_co_getlength =3D blk_log_writes_getlength, .bdrv_child_perm =3D blk_log_writes_child_perm, .bdrv_refresh_limits =3D blk_log_writes_refresh_limits, =20 diff --git a/block/blkreplay.c b/block/blkreplay.c index 76a0b8d12a..3c82af100a 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -135,7 +135,7 @@ static BlockDriver bdrv_blkreplay =3D { =20 .bdrv_open =3D blkreplay_open, .bdrv_child_perm =3D bdrv_default_perms, - .bdrv_getlength =3D blkreplay_getlength, + .bdrv_co_getlength =3D blkreplay_getlength, =20 .bdrv_co_preadv =3D blkreplay_co_preadv, .bdrv_co_pwritev =3D blkreplay_co_pwritev, diff --git a/block/blkverify.c b/block/blkverify.c index c60a2dc624..1a4bd68864 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -313,7 +313,7 @@ static BlockDriver bdrv_blkverify =3D { .bdrv_file_open =3D blkverify_open, .bdrv_close =3D blkverify_close, .bdrv_child_perm =3D bdrv_default_perms, - .bdrv_getlength =3D blkverify_getlength, + .bdrv_co_getlength =3D blkverify_getlength, .bdrv_refresh_filename =3D blkverify_refresh_filename, .bdrv_dirname =3D blkverify_dirname, =20 diff --git a/block/copy-on-read.c b/block/copy-on-read.c index ccc767f37b..ba76a1b3ec 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -249,7 +249,7 @@ static BlockDriver bdrv_copy_on_read =3D { .bdrv_close =3D cor_close, .bdrv_child_perm =3D cor_child_perm, =20 - .bdrv_getlength =3D cor_getlength, + .bdrv_co_getlength =3D cor_getlength, =20 .bdrv_co_preadv_part =3D cor_co_preadv_part, .bdrv_co_pwritev_part =3D cor_co_pwritev_part, @@ -257,8 +257,8 @@ static BlockDriver bdrv_copy_on_read =3D { .bdrv_co_pdiscard =3D cor_co_pdiscard, .bdrv_co_pwritev_compressed =3D cor_co_pwritev_compressed, =20 - .bdrv_eject =3D cor_eject, - .bdrv_lock_medium =3D cor_lock_medium, + .bdrv_co_eject =3D cor_eject, + .bdrv_co_lock_medium =3D cor_lock_medium, =20 .has_variable_length =3D true, .is_filter =3D true, diff --git a/block/crypto.c b/block/crypto.c index 12a84dd1cd..0df4fee46d 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -953,9 +953,9 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_refresh_limits =3D block_crypto_refresh_limits, .bdrv_co_preadv =3D block_crypto_co_preadv, .bdrv_co_pwritev =3D block_crypto_co_pwritev, - .bdrv_getlength =3D block_crypto_getlength, + .bdrv_co_getlength =3D block_crypto_getlength, .bdrv_measure =3D block_crypto_measure, - .bdrv_get_info =3D block_crypto_get_info_luks, + .bdrv_co_get_info =3D block_crypto_get_info_luks, .bdrv_get_specific_info =3D block_crypto_get_specific_info_luks, .bdrv_amend_options =3D block_crypto_amend_options_luks, .bdrv_co_amend =3D block_crypto_co_amend_luks, diff --git a/block/curl.c b/block/curl.c index cba4c4cac7..79735dfdc4 100644 --- a/block/curl.c +++ b/block/curl.c @@ -1001,7 +1001,7 @@ static BlockDriver bdrv_http =3D { .bdrv_parse_filename =3D curl_parse_filename, .bdrv_file_open =3D curl_open, .bdrv_close =3D curl_close, - .bdrv_getlength =3D curl_getlength, + .bdrv_co_getlength =3D curl_getlength, =20 .bdrv_co_preadv =3D curl_co_preadv, =20 @@ -1020,7 +1020,7 @@ static BlockDriver bdrv_https =3D { .bdrv_parse_filename =3D curl_parse_filename, .bdrv_file_open =3D curl_open, .bdrv_close =3D curl_close, - .bdrv_getlength =3D curl_getlength, + .bdrv_co_getlength =3D curl_getlength, =20 .bdrv_co_preadv =3D curl_co_preadv, =20 @@ -1039,7 +1039,7 @@ static BlockDriver bdrv_ftp =3D { .bdrv_parse_filename =3D curl_parse_filename, .bdrv_file_open =3D curl_open, .bdrv_close =3D curl_close, - .bdrv_getlength =3D curl_getlength, + .bdrv_co_getlength =3D curl_getlength, =20 .bdrv_co_preadv =3D curl_co_preadv, =20 @@ -1058,7 +1058,7 @@ static BlockDriver bdrv_ftps =3D { .bdrv_parse_filename =3D curl_parse_filename, .bdrv_file_open =3D curl_open, .bdrv_close =3D curl_close, - .bdrv_getlength =3D curl_getlength, + .bdrv_co_getlength =3D curl_getlength, =20 .bdrv_co_preadv =3D curl_co_preadv, =20 diff --git a/block/file-posix.c b/block/file-posix.c index b9647c5ffc..09f2615cbe 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3321,14 +3321,14 @@ BlockDriver bdrv_file =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, - .bdrv_io_plug =3D raw_aio_plug, - .bdrv_io_unplug =3D raw_aio_unplug, + .bdrv_co_io_plug =3D raw_aio_plug, + .bdrv_co_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, =20 .bdrv_co_truncate =3D raw_co_truncate, - .bdrv_getlength =3D raw_getlength, - .bdrv_get_info =3D raw_get_info, - .bdrv_get_allocated_file_size + .bdrv_co_getlength =3D raw_getlength, + .bdrv_co_get_info =3D raw_get_info, + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, .bdrv_get_specific_stats =3D raw_get_specific_stats, .bdrv_check_perm =3D raw_check_perm, @@ -3693,14 +3693,14 @@ static BlockDriver bdrv_host_device =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, - .bdrv_io_plug =3D raw_aio_plug, - .bdrv_io_unplug =3D raw_aio_unplug, + .bdrv_co_io_plug =3D raw_aio_plug, + .bdrv_co_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, =20 .bdrv_co_truncate =3D raw_co_truncate, - .bdrv_getlength =3D raw_getlength, - .bdrv_get_info =3D raw_get_info, - .bdrv_get_allocated_file_size + .bdrv_co_getlength =3D raw_getlength, + .bdrv_co_get_info =3D raw_get_info, + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, .bdrv_get_specific_stats =3D hdev_get_specific_stats, .bdrv_check_perm =3D raw_check_perm, @@ -3817,20 +3817,20 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, - .bdrv_io_plug =3D raw_aio_plug, - .bdrv_io_unplug =3D raw_aio_unplug, + .bdrv_co_io_plug =3D raw_aio_plug, + .bdrv_co_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, =20 .bdrv_co_truncate =3D raw_co_truncate, - .bdrv_getlength =3D raw_getlength, + .bdrv_co_getlength =3D raw_getlength, .has_variable_length =3D true, - .bdrv_get_allocated_file_size + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, =20 /* removable device support */ - .bdrv_is_inserted =3D cdrom_is_inserted, - .bdrv_eject =3D cdrom_eject, - .bdrv_lock_medium =3D cdrom_lock_medium, + .bdrv_co_is_inserted =3D cdrom_is_inserted, + .bdrv_co_eject =3D cdrom_eject, + .bdrv_co_lock_medium =3D cdrom_lock_medium, =20 /* generic scsi device */ .bdrv_co_ioctl =3D hdev_co_ioctl, @@ -3947,20 +3947,20 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, - .bdrv_io_plug =3D raw_aio_plug, - .bdrv_io_unplug =3D raw_aio_unplug, + .bdrv_co_io_plug =3D raw_aio_plug, + .bdrv_co_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, =20 .bdrv_co_truncate =3D raw_co_truncate, - .bdrv_getlength =3D raw_getlength, + .bdrv_co_getlength =3D raw_getlength, .has_variable_length =3D true, - .bdrv_get_allocated_file_size + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, =20 /* removable device support */ - .bdrv_is_inserted =3D cdrom_is_inserted, - .bdrv_eject =3D cdrom_eject, - .bdrv_lock_medium =3D cdrom_lock_medium, + .bdrv_co_is_inserted =3D cdrom_is_inserted, + .bdrv_co_eject =3D cdrom_eject, + .bdrv_co_lock_medium =3D cdrom_lock_medium, }; #endif /* __FreeBSD__ */ =20 diff --git a/block/file-win32.c b/block/file-win32.c index ec9d64d0e4..f611931631 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -763,8 +763,8 @@ BlockDriver bdrv_file =3D { .bdrv_aio_flush =3D raw_aio_flush, =20 .bdrv_co_truncate =3D raw_co_truncate, - .bdrv_getlength =3D raw_getlength, - .bdrv_get_allocated_file_size + .bdrv_co_getlength =3D raw_getlength, + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, =20 .create_opts =3D &raw_create_opts, @@ -932,10 +932,10 @@ static BlockDriver bdrv_host_device =3D { .bdrv_detach_aio_context =3D raw_detach_aio_context, .bdrv_attach_aio_context =3D raw_attach_aio_context, =20 - .bdrv_getlength =3D raw_getlength, + .bdrv_co_getlength =3D raw_getlength, .has_variable_length =3D true, =20 - .bdrv_get_allocated_file_size + .bdrv_co_get_allocated_file_size =3D raw_get_allocated_file_size, }; =20 diff --git a/block/filter-compress.c b/block/filter-compress.c index e10312c225..7b3fa2fd82 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -134,7 +134,7 @@ static BlockDriver bdrv_compress =3D { .bdrv_open =3D compress_open, .bdrv_child_perm =3D bdrv_default_perms, =20 - .bdrv_getlength =3D compress_getlength, + .bdrv_co_getlength =3D compress_getlength, =20 .bdrv_co_preadv_part =3D compress_co_preadv_part, .bdrv_co_pwritev_part =3D compress_co_pwritev_part, @@ -142,8 +142,8 @@ static BlockDriver bdrv_compress =3D { .bdrv_co_pdiscard =3D compress_co_pdiscard, .bdrv_refresh_limits =3D compress_refresh_limits, =20 - .bdrv_eject =3D compress_eject, - .bdrv_lock_medium =3D compress_lock_medium, + .bdrv_co_eject =3D compress_eject, + .bdrv_co_lock_medium =3D compress_lock_medium, =20 .has_variable_length =3D true, .is_filter =3D true, diff --git a/block/gluster.c b/block/gluster.c index 7c90f7ba4b..f15b522670 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1561,8 +1561,8 @@ static BlockDriver bdrv_gluster =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_co_create =3D qemu_gluster_co_create, .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_co_getlength =3D qemu_gluster_getlength, + .bdrv_co_get_allocated_file_size =3D qemu_gluster_allocated_file_size, .bdrv_co_truncate =3D qemu_gluster_co_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1590,8 +1590,8 @@ static BlockDriver bdrv_gluster_tcp =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_co_create =3D qemu_gluster_co_create, .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_co_getlength =3D qemu_gluster_getlength, + .bdrv_co_get_allocated_file_size =3D qemu_gluster_allocated_file_size, .bdrv_co_truncate =3D qemu_gluster_co_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1619,8 +1619,8 @@ static BlockDriver bdrv_gluster_unix =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_co_create =3D qemu_gluster_co_create, .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_co_getlength =3D qemu_gluster_getlength, + .bdrv_co_get_allocated_file_size =3D qemu_gluster_allocated_file_size, .bdrv_co_truncate =3D qemu_gluster_co_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1654,8 +1654,8 @@ static BlockDriver bdrv_gluster_rdma =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_co_create =3D qemu_gluster_co_create, .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_co_getlength =3D qemu_gluster_getlength, + .bdrv_co_get_allocated_file_size =3D qemu_gluster_allocated_file_size, .bdrv_co_truncate =3D qemu_gluster_co_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, diff --git a/block/io.c b/block/io.c index 48a94dd384..0ebe91ad04 100644 --- a/block/io.c +++ b/block/io.c @@ -2648,8 +2648,8 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVec= tor *qiov, int64_t pos) =20 bdrv_inc_in_flight(bs); =20 - if (drv->bdrv_load_vmstate) { - ret =3D drv->bdrv_load_vmstate(bs, qiov, pos); + if (drv->bdrv_co_load_vmstate) { + ret =3D drv->bdrv_co_load_vmstate(bs, qiov, pos); } else if (child_bs) { ret =3D bdrv_co_readv_vmstate(child_bs, qiov, pos); } else { @@ -2681,8 +2681,8 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVe= ctor *qiov, int64_t pos) =20 bdrv_inc_in_flight(bs); =20 - if (drv->bdrv_save_vmstate) { - ret =3D drv->bdrv_save_vmstate(bs, qiov, pos); + if (drv->bdrv_co_save_vmstate) { + ret =3D drv->bdrv_co_save_vmstate(bs, qiov, pos); } else if (child_bs) { ret =3D bdrv_co_writev_vmstate(child_bs, qiov, pos); } else { @@ -3080,8 +3080,8 @@ void coroutine_fn bdrv_co_io_plug(BlockDriverState *b= s) =20 if (qatomic_fetch_inc(&bs->io_plugged) =3D=3D 0) { BlockDriver *drv =3D bs->drv; - if (drv && drv->bdrv_io_plug) { - drv->bdrv_io_plug(bs); + if (drv && drv->bdrv_co_io_plug) { + drv->bdrv_co_io_plug(bs); } } } @@ -3095,8 +3095,8 @@ void coroutine_fn bdrv_co_io_unplug(BlockDriverState = *bs) assert(bs->io_plugged); if (qatomic_fetch_dec(&bs->io_plugged) =3D=3D 1) { BlockDriver *drv =3D bs->drv; - if (drv && drv->bdrv_io_unplug) { - drv->bdrv_io_unplug(bs); + if (drv && drv->bdrv_co_io_unplug) { + drv->bdrv_co_io_unplug(bs); } } =20 diff --git a/block/iscsi.c b/block/iscsi.c index a316d46d96..a5e54150fa 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2433,8 +2433,8 @@ static BlockDriver bdrv_iscsi =3D { .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, =20 - .bdrv_getlength =3D iscsi_getlength, - .bdrv_get_info =3D iscsi_get_info, + .bdrv_co_getlength =3D iscsi_getlength, + .bdrv_co_get_info =3D iscsi_get_info, .bdrv_co_truncate =3D iscsi_co_truncate, .bdrv_refresh_limits =3D iscsi_refresh_limits, =20 @@ -2472,8 +2472,8 @@ static BlockDriver bdrv_iser =3D { .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, =20 - .bdrv_getlength =3D iscsi_getlength, - .bdrv_get_info =3D iscsi_get_info, + .bdrv_co_getlength =3D iscsi_getlength, + .bdrv_co_get_info =3D iscsi_get_info, .bdrv_co_truncate =3D iscsi_co_truncate, .bdrv_refresh_limits =3D iscsi_refresh_limits, =20 diff --git a/block/nbd.c b/block/nbd.c index 5cad58aaf6..015875a392 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -2125,7 +2125,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, - .bdrv_getlength =3D nbd_getlength, + .bdrv_co_getlength =3D nbd_getlength, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_co_block_status =3D nbd_client_co_block_status, .bdrv_dirname =3D nbd_dirname, @@ -2153,7 +2153,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, - .bdrv_getlength =3D nbd_getlength, + .bdrv_co_getlength =3D nbd_getlength, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_co_block_status =3D nbd_client_co_block_status, .bdrv_dirname =3D nbd_dirname, @@ -2181,7 +2181,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, - .bdrv_getlength =3D nbd_getlength, + .bdrv_co_getlength =3D nbd_getlength, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_co_block_status =3D nbd_client_co_block_status, .bdrv_dirname =3D nbd_dirname, diff --git a/block/nfs.c b/block/nfs.c index ece22353ac..afecb582b2 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -884,7 +884,7 @@ static BlockDriver bdrv_nfs =3D { .bdrv_has_zero_init =3D nfs_has_zero_init, /* libnfs does not provide the allocated filesize of a file on win32. */ #if !defined(_WIN32) - .bdrv_get_allocated_file_size =3D nfs_get_allocated_file_size, + .bdrv_co_get_allocated_file_size =3D nfs_get_allocated_file_size, #endif .bdrv_co_truncate =3D nfs_file_co_truncate, =20 diff --git a/block/null.c b/block/null.c index 75f7d0db40..a2f52e112b 100644 --- a/block/null.c +++ b/block/null.c @@ -283,8 +283,8 @@ static BlockDriver bdrv_null_co =3D { =20 .bdrv_file_open =3D null_file_open, .bdrv_parse_filename =3D null_co_parse_filename, - .bdrv_getlength =3D null_getlength, - .bdrv_get_allocated_file_size =3D null_allocated_file_size, + .bdrv_co_getlength =3D null_getlength, + .bdrv_co_get_allocated_file_size =3D null_allocated_file_size, =20 .bdrv_co_preadv =3D null_co_preadv, .bdrv_co_pwritev =3D null_co_pwritev, @@ -304,8 +304,8 @@ static BlockDriver bdrv_null_aio =3D { =20 .bdrv_file_open =3D null_file_open, .bdrv_parse_filename =3D null_aio_parse_filename, - .bdrv_getlength =3D null_getlength, - .bdrv_get_allocated_file_size =3D null_allocated_file_size, + .bdrv_co_getlength =3D null_getlength, + .bdrv_co_get_allocated_file_size =3D null_allocated_file_size, =20 .bdrv_aio_preadv =3D null_aio_preadv, .bdrv_aio_pwritev =3D null_aio_pwritev, diff --git a/block/nvme.c b/block/nvme.c index 656624c585..9be9722029 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1642,7 +1642,7 @@ static BlockDriver bdrv_nvme =3D { .bdrv_parse_filename =3D nvme_parse_filename, .bdrv_file_open =3D nvme_file_open, .bdrv_close =3D nvme_close, - .bdrv_getlength =3D nvme_getlength, + .bdrv_co_getlength =3D nvme_getlength, .bdrv_probe_blocksizes =3D nvme_probe_blocksizes, .bdrv_co_truncate =3D nvme_co_truncate, =20 @@ -1663,8 +1663,8 @@ static BlockDriver bdrv_nvme =3D { .bdrv_detach_aio_context =3D nvme_detach_aio_context, .bdrv_attach_aio_context =3D nvme_attach_aio_context, =20 - .bdrv_io_plug =3D nvme_aio_plug, - .bdrv_io_unplug =3D nvme_aio_unplug, + .bdrv_co_io_plug =3D nvme_aio_plug, + .bdrv_co_io_unplug =3D nvme_aio_unplug, =20 .bdrv_register_buf =3D nvme_register_buf, .bdrv_unregister_buf =3D nvme_unregister_buf, diff --git a/block/preallocate.c b/block/preallocate.c index d50ee7f49b..584a8b5912 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -536,7 +536,7 @@ BlockDriver bdrv_preallocate_filter =3D { .format_name =3D "preallocate", .instance_size =3D sizeof(BDRVPreallocateState), =20 - .bdrv_getlength =3D preallocate_getlength, + .bdrv_co_getlength =3D preallocate_getlength, .bdrv_open =3D preallocate_open, .bdrv_close =3D preallocate_close, =20 diff --git a/block/qcow.c b/block/qcow.c index daa38839ab..167c135dbe 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1198,7 +1198,7 @@ static BlockDriver bdrv_qcow =3D { =20 .bdrv_make_empty =3D qcow_make_empty, .bdrv_co_pwritev_compressed =3D qcow_co_pwritev_compressed, - .bdrv_get_info =3D qcow_get_info, + .bdrv_co_get_info =3D qcow_get_info, =20 .create_opts =3D &qcow_create_opts, .strong_runtime_opts =3D qcow_strong_runtime_opts, diff --git a/block/qcow2.c b/block/qcow2.c index 4d6666d3ff..7bdb310db3 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -6078,11 +6078,11 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_snapshot_list =3D qcow2_snapshot_list, .bdrv_snapshot_load_tmp =3D qcow2_snapshot_load_tmp, .bdrv_measure =3D qcow2_measure, - .bdrv_get_info =3D qcow2_get_info, + .bdrv_co_get_info =3D qcow2_get_info, .bdrv_get_specific_info =3D qcow2_get_specific_info, =20 - .bdrv_save_vmstate =3D qcow2_save_vmstate, - .bdrv_load_vmstate =3D qcow2_load_vmstate, + .bdrv_co_save_vmstate =3D qcow2_save_vmstate, + .bdrv_co_load_vmstate =3D qcow2_load_vmstate, =20 .is_format =3D true, .supports_backing =3D true, diff --git a/block/qed.c b/block/qed.c index 778b23d0f6..f83fcbd4c8 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1656,8 +1656,8 @@ static BlockDriver bdrv_qed =3D { .bdrv_co_writev =3D bdrv_qed_co_writev, .bdrv_co_pwrite_zeroes =3D bdrv_qed_co_pwrite_zeroes, .bdrv_co_truncate =3D bdrv_qed_co_truncate, - .bdrv_getlength =3D bdrv_qed_getlength, - .bdrv_get_info =3D bdrv_qed_get_info, + .bdrv_co_getlength =3D bdrv_qed_getlength, + .bdrv_co_get_info =3D bdrv_qed_get_info, .bdrv_refresh_limits =3D bdrv_qed_refresh_limits, .bdrv_change_backing_file =3D bdrv_qed_change_backing_file, .bdrv_co_invalidate_cache =3D bdrv_qed_co_invalidate_cache, diff --git a/block/quorum.c b/block/quorum.c index f9e6539ceb..ce5090d31a 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1283,7 +1283,7 @@ static BlockDriver bdrv_quorum =3D { =20 .bdrv_co_flush =3D quorum_co_flush, =20 - .bdrv_getlength =3D quorum_getlength, + .bdrv_co_getlength =3D quorum_getlength, =20 .bdrv_co_preadv =3D quorum_co_preadv, .bdrv_co_pwritev =3D quorum_co_pwritev, diff --git a/block/raw-format.c b/block/raw-format.c index 96a9b33384..87d997d640 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -621,16 +621,16 @@ BlockDriver bdrv_raw =3D { .bdrv_co_copy_range_from =3D &raw_co_copy_range_from, .bdrv_co_copy_range_to =3D &raw_co_copy_range_to, .bdrv_co_truncate =3D &raw_co_truncate, - .bdrv_getlength =3D &raw_getlength, + .bdrv_co_getlength =3D &raw_getlength, .is_format =3D true, .has_variable_length =3D true, .bdrv_measure =3D &raw_measure, - .bdrv_get_info =3D &raw_get_info, + .bdrv_co_get_info =3D &raw_get_info, .bdrv_refresh_limits =3D &raw_refresh_limits, .bdrv_probe_blocksizes =3D &raw_probe_blocksizes, .bdrv_probe_geometry =3D &raw_probe_geometry, - .bdrv_eject =3D &raw_eject, - .bdrv_lock_medium =3D &raw_lock_medium, + .bdrv_co_eject =3D &raw_eject, + .bdrv_co_lock_medium =3D &raw_lock_medium, .bdrv_co_ioctl =3D &raw_co_ioctl, .create_opts =3D &raw_create_opts, .bdrv_has_zero_init =3D &raw_has_zero_init, diff --git a/block/rbd.c b/block/rbd.c index f826410f40..a0317d470a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1655,10 +1655,10 @@ static BlockDriver bdrv_rbd =3D { .bdrv_co_create =3D qemu_rbd_co_create, .bdrv_co_create_opts =3D qemu_rbd_co_create_opts, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, - .bdrv_get_info =3D qemu_rbd_getinfo, + .bdrv_co_get_info =3D qemu_rbd_getinfo, .bdrv_get_specific_info =3D qemu_rbd_get_specific_info, .create_opts =3D &qemu_rbd_create_opts, - .bdrv_getlength =3D qemu_rbd_getlength, + .bdrv_co_getlength =3D qemu_rbd_getlength, .bdrv_co_truncate =3D qemu_rbd_co_truncate, .protocol_name =3D "rbd", =20 diff --git a/block/replication.c b/block/replication.c index c62f48a874..321db05465 100644 --- a/block/replication.c +++ b/block/replication.c @@ -758,7 +758,7 @@ static BlockDriver bdrv_replication =3D { .bdrv_close =3D replication_close, .bdrv_child_perm =3D replication_child_perm, =20 - .bdrv_getlength =3D replication_getlength, + .bdrv_co_getlength =3D replication_getlength, .bdrv_co_readv =3D replication_co_readv, .bdrv_co_writev =3D replication_co_writev, =20 diff --git a/block/ssh.c b/block/ssh.c index 04726d4ecb..c70db1e4e2 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1363,7 +1363,7 @@ static BlockDriver bdrv_ssh =3D { .bdrv_has_zero_init =3D ssh_has_zero_init, .bdrv_co_readv =3D ssh_co_readv, .bdrv_co_writev =3D ssh_co_writev, - .bdrv_getlength =3D ssh_getlength, + .bdrv_co_getlength =3D ssh_getlength, .bdrv_co_truncate =3D ssh_co_truncate, .bdrv_co_flush_to_disk =3D ssh_co_flush, .bdrv_refresh_filename =3D ssh_refresh_filename, diff --git a/block/throttle.c b/block/throttle.c index 88851c84f4..260ffeace2 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -245,7 +245,7 @@ static BlockDriver bdrv_throttle =3D { =20 .bdrv_child_perm =3D bdrv_default_perms, =20 - .bdrv_getlength =3D throttle_getlength, + .bdrv_co_getlength =3D throttle_getlength, =20 .bdrv_co_preadv =3D throttle_co_preadv, .bdrv_co_pwritev =3D throttle_co_pwritev, diff --git a/block/vdi.c b/block/vdi.c index c0c111c4b9..6e4bf24e8c 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -1049,7 +1049,7 @@ static BlockDriver bdrv_vdi =3D { .bdrv_co_pwritev =3D vdi_co_pwritev, #endif =20 - .bdrv_get_info =3D vdi_get_info, + .bdrv_co_get_info =3D vdi_get_info, =20 .is_format =3D true, .create_opts =3D &vdi_create_opts, diff --git a/block/vhdx.c b/block/vhdx.c index bad9ca691b..85c6f8b68e 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2245,7 +2245,7 @@ static BlockDriver bdrv_vhdx =3D { .bdrv_co_writev =3D vhdx_co_writev, .bdrv_co_create =3D vhdx_co_create, .bdrv_co_create_opts =3D vhdx_co_create_opts, - .bdrv_get_info =3D vhdx_get_info, + .bdrv_co_get_info =3D vhdx_get_info, .bdrv_co_check =3D vhdx_co_check, .bdrv_has_zero_init =3D vhdx_has_zero_init, =20 diff --git a/block/vmdk.c b/block/vmdk.c index 0c32bf2e83..768ce89a08 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -3130,11 +3130,11 @@ static BlockDriver bdrv_vmdk =3D { .bdrv_co_create_opts =3D vmdk_co_create_opts, .bdrv_co_create =3D vmdk_co_create, .bdrv_co_block_status =3D vmdk_co_block_status, - .bdrv_get_allocated_file_size =3D vmdk_get_allocated_file_size, + .bdrv_co_get_allocated_file_size =3D vmdk_get_allocated_file_size, .bdrv_has_zero_init =3D vmdk_has_zero_init, .bdrv_get_specific_info =3D vmdk_get_specific_info, .bdrv_refresh_limits =3D vmdk_refresh_limits, - .bdrv_get_info =3D vmdk_get_info, + .bdrv_co_get_info =3D vmdk_get_info, .bdrv_gather_child_options =3D vmdk_gather_child_options, =20 .is_format =3D true, diff --git a/block/vpc.c b/block/vpc.c index 95841f259a..96c25975a0 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1240,7 +1240,7 @@ static BlockDriver bdrv_vpc =3D { .bdrv_co_pwritev =3D vpc_co_pwritev, .bdrv_co_block_status =3D vpc_co_block_status, =20 - .bdrv_get_info =3D vpc_get_info, + .bdrv_co_get_info =3D vpc_get_info, =20 .is_format =3D true, .create_opts =3D &vpc_create_opts, diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 3ab3fa45a2..0bc180a585 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -724,9 +724,10 @@ struct BlockDriver { bool exact, PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp); /* Called with graph rdlock held. */ - int64_t coroutine_fn (*bdrv_getlength)(BlockDriverState *bs); + int64_t coroutine_fn (*bdrv_co_getlength)(BlockDriverState *bs); /* Called with graph rdlock held. */ - int64_t coroutine_fn (*bdrv_get_allocated_file_size)(BlockDriverState = *bs); + int64_t coroutine_fn (*bdrv_co_get_allocated_file_size) + (BlockDriverState = *bs); =20 /* Does not need graph rdlock, since it does not traverse the graph */ BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in= _bs, @@ -741,7 +742,7 @@ struct BlockDriver { size_t qiov_offset); =20 /* Called with graph rdlock held. */ - int coroutine_fn (*bdrv_get_info)(BlockDriverState *bs, + int coroutine_fn (*bdrv_co_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); =20 /* Does not need graph rdlock, since it does not traverse the graph */ @@ -751,18 +752,18 @@ struct BlockDriver { BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs); =20 /* Called with graph rdlock held. */ - int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, - QEMUIOVector *qiov, - int64_t pos); + int coroutine_fn (*bdrv_co_save_vmstate)(BlockDriverState *bs, + QEMUIOVector *qiov, + int64_t pos); /* Called with graph rdlock held. */ - int coroutine_fn (*bdrv_load_vmstate)(BlockDriverState *bs, + int coroutine_fn (*bdrv_co_load_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); =20 /* removable device specific. Called with graph rdlock held. */ - bool coroutine_fn (*bdrv_is_inserted)(BlockDriverState *bs); - void coroutine_fn (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); - void coroutine_fn (*bdrv_lock_medium)(BlockDriverState *bs, bool locke= d); + bool coroutine_fn (*bdrv_co_is_inserted)(BlockDriverState *bs); + void coroutine_fn (*bdrv_co_eject)(BlockDriverState *bs, bool eject_fl= ag); + void coroutine_fn (*bdrv_co_lock_medium)(BlockDriverState *bs, bool lo= cked); =20 /* to control generic scsi devices. Called with graph rdlock taken. */ BlockAIOCB *coroutine_fn (*bdrv_aio_ioctl)(BlockDriverState *bs, @@ -782,12 +783,12 @@ struct BlockDriver { BdrvCheckMode fix); =20 /* Called with graph rdlock taken. */ - void coroutine_fn (*bdrv_debug_event)(BlockDriverState *bs, + void coroutine_fn (*bdrv_co_debug_event)(BlockDriverState *bs, BlkdebugEvent event); =20 /* io queue for linux-aio. Called with graph rdlock taken. */ - void coroutine_fn (*bdrv_io_plug)(BlockDriverState *bs); - void coroutine_fn (*bdrv_io_unplug)(BlockDriverState *bs); + void coroutine_fn (*bdrv_co_io_plug)(BlockDriverState *bs); + void coroutine_fn (*bdrv_co_io_unplug)(BlockDriverState *bs); =20 /** * bdrv_drain_begin is called if implemented in the beginning of a --=20 2.31.1