From nobody Mon Feb 9 12:10:22 2026 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=1558628124; cv=none; d=zoho.com; s=zohoarc; b=nZiijIID37CDqNr2EeDzS6+x5bb2JTa6DuSH9NCoX9+tbIJxvIc7l9i4lL4mJeigpLJb/ZChR+gCjHLGL+jk9zHJZPtNDfFA3Ywgw09xb7oVSVk/spwOsnL99XEkL/ZcBk/9atNDFpWDjRdx1l33N6vf0G0ULj03TDEL0XseufM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558628124; 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=Im6sMigjooxyODoY4Ic24hOeZCfhtn7nd/0qzF77pGA=; b=mXcr21TgBYK6jBDsYv4n3YaABaXVnpgyrh/WkPqW+4cAp3mYlnk7BqW9mpxwUiQC6s9RXULirxRZ0EZ84fQ1ddoMIacrV00EZL7GPxseHF1TojoaNu7uoAj5W+FyqHRQsjlelb9CvNGyGB/FCbKhzbE9hBRH2+F8EI8XSd6ppds= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558628124816946.7303487722185; Thu, 23 May 2019 09:15:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:40118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTqN9-00084l-Nl for importer@patchew.org; Thu, 23 May 2019 12:15:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTqAP-0004bt-L2 for qemu-devel@nongnu.org; Thu, 23 May 2019 12:02:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTqAK-00029f-MY for qemu-devel@nongnu.org; Thu, 23 May 2019 12:02:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41786) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTqAF-0001vQ-0V; Thu, 23 May 2019 12:01:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F34A0C0A4F7D; Thu, 23 May 2019 16:01:44 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-143.ams2.redhat.com [10.36.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1D801001E6F; Thu, 23 May 2019 16:01:43 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 23 May 2019 18:01:04 +0200 Message-Id: <20190523160104.21258-16-kwolf@redhat.com> In-Reply-To: <20190523160104.21258-1-kwolf@redhat.com> References: <20190523160104.21258-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 May 2019 16:01:45 +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] [PATCH 15/15] block: Remove 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, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" All callers of bdrv_set_aio_context() are eliminated now, they have moved to bdrv_try_set_aio_context() and related safe functions. Remove bdrv_set_aio_context(). With this, we can now know that the .set_aio_ctx callback must be present in bdrv_set_aio_context_ignore() because bdrv_can_set_aio_context() would have returned false previously, so instead of checking the condition, we can assert it. Signed-off-by: Kevin Wolf --- docs/devel/multiple-iothreads.txt | 4 ++-- include/block/block.h | 9 --------- block.c | 30 ++++++++++++++---------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/docs/devel/multiple-iothreads.txt b/docs/devel/multiple-iothre= ads.txt index 4f9012d154..aeb997bed5 100644 --- a/docs/devel/multiple-iothreads.txt +++ b/docs/devel/multiple-iothreads.txt @@ -109,7 +109,7 @@ The AioContext originates from the QEMU block layer, ev= en though nowadays AioContext is a generic event loop that can be used by any QEMU subsystem. =20 The block layer has support for AioContext integrated. Each BlockDriverSt= ate -is associated with an AioContext using bdrv_set_aio_context() and +is associated with an AioContext using bdrv_try_set_aio_context() and bdrv_get_aio_context(). This allows block layer code to process I/O insid= e the right AioContext. Other subsystems may wish to follow a similar approach. =20 @@ -134,5 +134,5 @@ Long-running jobs (usually in the form of coroutines) a= re best scheduled in the BlockDriverState's AioContext to avoid the need to acquire/release aro= und each bdrv_*() call. The functions bdrv_add/remove_aio_context_notifier, or alternatively blk_add/remove_aio_context_notifier if you use BlockBacke= nds, -can be used to get a notification whenever bdrv_set_aio_context() moves a +can be used to get a notification whenever bdrv_try_set_aio_context() move= s a BlockDriverState to a different AioContext. diff --git a/include/block/block.h b/include/block/block.h index 531cf595cf..13ea050a5b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -583,15 +583,6 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs); */ void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co); =20 -/** - * bdrv_set_aio_context: - * - * Changes the #AioContext used for fd handlers, timers, and BHs by this - * BlockDriverState and all its children. - * - * This function must be called with iothread lock held. - */ -void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context); void bdrv_set_aio_context_ignore(BlockDriverState *bs, AioContext *new_context, GSList **ignore); int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx, diff --git a/block.c b/block.c index e9261c650d..628f65c41a 100644 --- a/block.c +++ b/block.c @@ -5791,8 +5791,17 @@ static void bdrv_attach_aio_context(BlockDriverState= *bs, bs->walking_aio_notifiers =3D false; } =20 -/* @ignore will accumulate all visited BdrvChild object. The caller is - * responsible for freeing the list afterwards. */ +/* + * Changes the AioContext used for fd handlers, timers, and BHs by this + * BlockDriverState and all its children and parents. + * + * The caller must own the AioContext lock for the old AioContext of bs, b= ut it + * must not own the AioContext lock for new_context (unless new_context is= the + * same as the current context of bs). + * + * @ignore will accumulate all visited BdrvChild object. The caller is + * responsible for freeing the list afterwards. + */ void bdrv_set_aio_context_ignore(BlockDriverState *bs, AioContext *new_context, GSList **ignore) { @@ -5815,10 +5824,9 @@ void bdrv_set_aio_context_ignore(BlockDriverState *b= s, if (g_slist_find(*ignore, child)) { continue; } - if (child->role->set_aio_ctx) { - *ignore =3D g_slist_prepend(*ignore, child); - child->role->set_aio_ctx(child, new_context, ignore); - } + assert(child->role->set_aio_ctx); + *ignore =3D g_slist_prepend(*ignore, child); + child->role->set_aio_ctx(child, new_context, ignore); } =20 bdrv_detach_aio_context(bs); @@ -5832,16 +5840,6 @@ void bdrv_set_aio_context_ignore(BlockDriverState *b= s, aio_context_release(new_context); } =20 -/* The caller must own the AioContext lock for the old AioContext of bs, b= ut it - * must not own the AioContext lock for new_context (unless new_context is - * the same as the current context of bs). */ -void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context) -{ - GSList *ignore_list =3D NULL; - bdrv_set_aio_context_ignore(bs, new_context, &ignore_list); - g_slist_free(ignore_list); -} - static bool bdrv_parent_can_set_aio_context(BdrvChild *c, AioContext *ctx, GSList **ignore, Error **errp) { --=20 2.20.1