From nobody Wed Apr 16 03:53:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558369483; cv=none; d=zoho.com; s=zohoarc; b=LPIw4HE+FLnd5/Z53VK3pgq62lpiUQB61bY+cNLeQbHqPjUaQ22IB27kC6TDUnBTRgjxG44vHacH+mtg4x6jvhvcgQ6JApP40z070HC/Myboja/WKLlLGaJs1vj+eaBDdv3Xv+oIYEpPDFIjRYLamSxguaxo8XV0umZojUZohbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558369483; 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:ARC-Authentication-Results; bh=dqnw43ZALwblgdJzCARy8YIApnPZfp1GwuRqmaq+T6o=; b=ii8GCAr64dizp7Tjc+RhNW+r6PUcPu0pFncPTVflHGJGkYRX5nQsX+JElRUHoaTX8pqgMo2RdPCu04DGGD/Ymsmos0n3sv/sIC/j3hPKTKG5etyAx5FtqxQhxklvNEfy/d2G/GdbZNNeEL6JHudFqbznlanXruLcB2NsSzfUx7Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155836948313296.51795695047679; Mon, 20 May 2019 09:24:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:38128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSl51-0006rz-HX for importer@patchew.org; Mon, 20 May 2019 12:24:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSkwr-0008FH-AJ for qemu-devel@nongnu.org; Mon, 20 May 2019 12:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSkwq-0003Yu-9d for qemu-devel@nongnu.org; Mon, 20 May 2019 12:15:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hSkwm-0003QM-O5; Mon, 20 May 2019 12:15:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAF9E3082B43; Mon, 20 May 2019 16:15:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-208.ams2.redhat.com [10.36.117.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4272601A0; Mon, 20 May 2019 16:15:17 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 20 May 2019 18:14:38 +0200 Message-Id: <20190520161453.30723-10-kwolf@redhat.com> In-Reply-To: <20190520161453.30723-1-kwolf@redhat.com> References: <20190520161453.30723-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 20 May 2019 16:15:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/24] block: Move recursion to bdrv_set_aio_context() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of having two recursions, in bdrv_attach_aio_context() and in bdrv_detach_aio_context(), just having one recursion is enough. Said functions are only about a single node now. It is important that the recursion doesn't happen between detaching and attaching a context to the current node because the nested call will drain the node, and draining with a NULL context would segfault. Signed-off-by: Kevin Wolf --- block.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index b2f71142a5..0ace673925 100644 --- a/block.c +++ b/block.c @@ -5679,7 +5679,6 @@ static void bdrv_do_remove_aio_context_notifier(BdrvA= ioNotifier *ban) static void bdrv_detach_aio_context(BlockDriverState *bs) { BdrvAioNotifier *baf, *baf_tmp; - BdrvChild *child; =20 assert(!bs->walking_aio_notifiers); bs->walking_aio_notifiers =3D true; @@ -5698,9 +5697,6 @@ static void bdrv_detach_aio_context(BlockDriverState = *bs) if (bs->drv && bs->drv->bdrv_detach_aio_context) { bs->drv->bdrv_detach_aio_context(bs); } - QLIST_FOREACH(child, &bs->children, next) { - bdrv_detach_aio_context(child->bs); - } =20 if (bs->quiesce_counter) { aio_enable_external(bs->aio_context); @@ -5712,7 +5708,6 @@ static void bdrv_attach_aio_context(BlockDriverState = *bs, AioContext *new_context) { BdrvAioNotifier *ban, *ban_tmp; - BdrvChild *child; =20 if (bs->quiesce_counter) { aio_disable_external(new_context); @@ -5720,9 +5715,6 @@ static void bdrv_attach_aio_context(BlockDriverState = *bs, =20 bs->aio_context =3D new_context; =20 - QLIST_FOREACH(child, &bs->children, next) { - bdrv_attach_aio_context(child->bs, new_context); - } if (bs->drv && bs->drv->bdrv_attach_aio_context) { bs->drv->bdrv_attach_aio_context(bs, new_context); } @@ -5744,11 +5736,18 @@ static void bdrv_attach_aio_context(BlockDriverStat= e *bs, * the same as the current context of bs). */ void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context) { + BdrvChild *child; + if (bdrv_get_aio_context(bs) =3D=3D new_context) { return; } =20 bdrv_drained_begin(bs); + + QLIST_FOREACH(child, &bs->children, next) { + bdrv_set_aio_context(child->bs, new_context); + } + bdrv_detach_aio_context(bs); =20 /* This function executes in the old AioContext so acquire the new one= in --=20 2.20.1