From nobody Mon Feb 9 08:10:40 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1658751865; cv=none; d=zohomail.com; s=zohoarc; b=ml/1EupUFjrZiNbGN1igGdLAWFWNoAdLJC2TLfRvQ29lDBQb3FFOuys58CzYB5PW2z/0BUXzCxPDm2AlysjtusdZi/GPUuSmUHTlosB6dlSqMPrgz7eFhOCg40z+XS7nanaVVc7GC5zgZvhwmvptqqabcrHTykDzG7Hr4j0bLww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658751865; 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=Bx79kqpmq1a7uj5+8p7ruAYDnXjpbMAKJvdsMpPZ064=; b=gKFeGDcAbZUVpwny5SeeMn9htwfgJKSj2TcbT43GGVdW8OHn9B8KoxfomvBB3DRTiLRsh58YBTt5l4YSRRkTaz4ax9/KqfbO5uFBnpm2/c37mEQX3AgYmulC0DAaTne6Z+8gJwapDOmLdbA+/lFerULlgHwRFw2bL2XPiuNEDEw= 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 1658751865319306.9491635165473; Mon, 25 Jul 2022 05:24:25 -0700 (PDT) Received: from localhost ([::1]:57076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFx8K-0005yW-AQ for importer@patchew.org; Mon, 25 Jul 2022 08:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFx5Z-0002Xa-Cd for qemu-devel@nongnu.org; Mon, 25 Jul 2022 08:21:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36237) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFx5U-00061m-GM for qemu-devel@nongnu.org; Mon, 25 Jul 2022 08:21:30 -0400 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-300-2peHmXULPDm9J2gnfzMv7A-1; Mon, 25 Jul 2022 08:21:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3687318F0271; Mon, 25 Jul 2022 12:21:24 +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 CBB6218EB5; Mon, 25 Jul 2022 12:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658751688; 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=Bx79kqpmq1a7uj5+8p7ruAYDnXjpbMAKJvdsMpPZ064=; b=No8muXSsjlAXW2yusSNRgTppq7yzrJ9Y8PN5YRqauUlKQPqBN/E19epfUdG1x9XkxKHuPl roKYlyLDsIGYrluIjFWtuC47xrVLCja0fVhbHvKJT8wrQXzaoW9sgVWzn1akxft9sEJCGw 8162vDKcM01XbLFbwahcWjdRYEWw14c= X-MC-Unique: 2peHmXULPDm9J2gnfzMv7A-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Stefan Hajnoczi , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v2 04/11] bdrv_child_try_change_aio_context: add transaction parameter Date: Mon, 25 Jul 2022 08:21:13 -0400 Message-Id: <20220725122120.309236-5-eesposit@redhat.com> In-Reply-To: <20220725122120.309236-1-eesposit@redhat.com> References: <20220725122120.309236-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658751867867100001 Content-Type: text/plain; charset="utf-8" This enables the caller to use the same transaction to also keep track of aiocontext changes. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 31 ++++++++++++++++++++++++------ include/block/block-global-state.h | 5 +++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index c02a628336..221bf90268 100644 --- a/block.c +++ b/block.c @@ -7643,17 +7643,16 @@ int bdrv_child_try_set_aio_context(BlockDriverState= *bs, AioContext *ctx, * For the same reason, it temporarily holds also the new AioContext, since * bdrv_drained_end calls BDRV_POLL_WHILE that assumes the lock is taken t= oo. */ -int bdrv_child_try_change_aio_context(BlockDriverState *bs, AioContext *ct= x, - BdrvChild *ignore_child, Error **err= p) +int bdrv_child_try_change_aio_context_tran(BlockDriverState *bs, + AioContext *ctx, + BdrvChild *ignore_child, + Transaction *tran, + Error **errp) { - Transaction *tran; GHashTable *visited; int ret; - AioContext *old_context =3D bdrv_get_aio_context(bs); GLOBAL_STATE_CODE(); =20 - /* Recursion phase: go through all nodes of the graph */ - tran =3D tran_new(); visited =3D g_hash_table_new(NULL, NULL); if (ignore_child) { g_hash_table_add(visited, ignore_child); @@ -7661,6 +7660,26 @@ int bdrv_child_try_change_aio_context(BlockDriverSta= te *bs, AioContext *ctx, ret =3D bdrv_change_aio_context(bs, ctx, visited, tran, errp); g_hash_table_destroy(visited); =20 + return ret; +} + +/* + * See bdrv_child_try_change_aio_context_tran for invariants on + * AioContext locks. + */ +int bdrv_child_try_change_aio_context(BlockDriverState *bs, AioContext *ct= x, + BdrvChild *ignore_child, Error **err= p) +{ + Transaction *tran; + int ret; + AioContext *old_context =3D bdrv_get_aio_context(bs); + GLOBAL_STATE_CODE(); + + /* Recursion phase: go through all nodes of the graph */ + tran =3D tran_new(); + ret =3D bdrv_child_try_change_aio_context_tran(bs, ctx, ignore_child, = tran, + errp); + /* Linear phase: go through all callbacks collected in the transaction= */ =20 if (!ret) { diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index ceecf0aa8e..1bd445b507 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -234,6 +234,11 @@ bool bdrv_child_change_aio_context(BdrvChild *c, AioCo= ntext *ctx, Error **errp); int bdrv_child_try_change_aio_context(BlockDriverState *bs, AioContext *ct= x, BdrvChild *ignore_child, Error **err= p); +int bdrv_child_try_change_aio_context_tran(BlockDriverState *bs, + AioContext *ctx, + BdrvChild *ignore_child, + Transaction *tran, + Error **errp); =20 int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz); int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); --=20 2.31.1