From nobody Wed Dec 17 22:00:39 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=1559575703; cv=none; d=zoho.com; s=zohoarc; b=VmJ1VmfVCEx4W3zR2yDP4CENPzH+jDY9si4GLf1bMScLQ1VevtZCDW8SHWLCH7Lp1EjPigvvkddESLrJ/Qq8YN9TkPPOIXcZq90WchcbldsIgxoLmYqetjKd/iJVgFrXOoVECGoH6joHhtyDSbKA6AAlvOeAt0xLkj4hTPiKGyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559575703; 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=Fe2SYw4mTClrH4S89UoCoR5xb4CiydKgptTDjFffoes=; b=UoJdy/PjyxmKCpJxFR6pHp0+OF+0bpg5aay3Ict+z4zPWVXNd+lhi2RFEcCHEEMhEp1865DVM99JD/FCcKe2sGDOgoLLR/n+t26+WoKloeEZ949oWsDVgTE1LeyDb9uWPqf0LBjuz45pw2/B3agfB2K2L7285NR8AwtAtKZdgAg= 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 1559575703200745.2367288442582; Mon, 3 Jun 2019 08:28:23 -0700 (PDT) Received: from localhost ([127.0.0.1]:36695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXosf-0003aN-3S for importer@patchew.org; Mon, 03 Jun 2019 11:28:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXoWE-0001hb-9H for qemu-devel@nongnu.org; Mon, 03 Jun 2019 11:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXoW8-0001ei-1i for qemu-devel@nongnu.org; Mon, 03 Jun 2019 11:04:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXoW2-0001Rz-9E; Mon, 03 Jun 2019 11:04:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DC5DC05B1CA; Mon, 3 Jun 2019 15:04:42 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA33A67279; Mon, 3 Jun 2019 15:04:39 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 3 Jun 2019 17:02:30 +0200 Message-Id: <20190603150233.6614-26-kwolf@redhat.com> In-Reply-To: <20190603150233.6614-1-kwolf@redhat.com> References: <20190603150233.6614-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 03 Jun 2019 15:04:43 +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 25/28] 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 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 ddfae15d9b..e3e77feee0 100644 --- a/block.c +++ b/block.c @@ -5789,8 +5789,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) { @@ -5813,10 +5822,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); @@ -5830,16 +5838,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