From nobody Wed Apr 16 08:21:10 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=1558369532; cv=none; d=zoho.com; s=zohoarc; b=XIEMlFYjgzXrp1KMu09FL53SzH9sOKdJNrjMbYPYPEopLudbiyvjaxINixdUnLFbEDAwQzLe7rNAZMaUZlLoWi+dSrHMw2uSRqw0PMQvcUgmFdmdGMG9CLQQds3Wb2oM/58IJWVSfZB/H8H0/BNj0gWp4OsGmsxgL0V+K1EcJQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558369532; 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=qu3sOt51fy9FIHu0+iaoQ2CTJU8TGqB2bLcRGo3bCXo=; b=G9ytZJAEJmIxLdUBZ1RbmiGD2CSQWhr4Wgg/derGQZ8gBnuWf2V93WAVN2D16rbfdEQsRgROx/GfnM9SYwhBfJP/cYHySADU3wQPnw2LFoISo6O8FIlitXkBiwNQldpNYb0vR+C87EyA864/ugbgYk/Klf/2v8LpRRLbHkB6Ans= 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 1558369532190831.9376106406235; Mon, 20 May 2019 09:25:32 -0700 (PDT) Received: from localhost ([127.0.0.1]:38134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSl6L-0007xH-54 for importer@patchew.org; Mon, 20 May 2019 12:25:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSkx7-00005W-G5 for qemu-devel@nongnu.org; Mon, 20 May 2019 12:15:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSkx4-0003iM-Kp for qemu-devel@nongnu.org; Mon, 20 May 2019 12:15:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hSkwz-0003ea-Ez; Mon, 20 May 2019 12:15:45 -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 BE1F9309B143; Mon, 20 May 2019 16:15:36 +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 D16BF78386; Mon, 20 May 2019 16:15:35 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 20 May 2019 18:14:44 +0200 Message-Id: <20190520161453.30723-16-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.49]); Mon, 20 May 2019 16:15:39 +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 15/24] blockjob: Remove AioContext notifiers 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" The notifiers made sure that the job is quiesced and that the job->aio_context field is updated. The first part is unnecessary today since bdrv_set_aio_context_ignore() drains the block node, and this means drainig the block job, too. The second part can be done in the .set_aio_ctx callback of the block job BdrvChildRole. The notifiers were problematic because they poll the AioContext while the graph is in an inconsistent state with some nodes already in the new context, but others still in the old context. So removing the notifiers not only simplifies the code, but actually makes the code safer. Signed-off-by: Kevin Wolf --- blockjob.c | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/blockjob.c b/blockjob.c index 24e6093a9c..9ca942ba01 100644 --- a/blockjob.c +++ b/blockjob.c @@ -81,10 +81,6 @@ BlockJob *block_job_get(const char *id) } } =20 -static void block_job_attached_aio_context(AioContext *new_context, - void *opaque); -static void block_job_detach_aio_context(void *opaque); - void block_job_free(Job *job) { BlockJob *bjob =3D container_of(job, BlockJob, job); @@ -92,28 +88,10 @@ void block_job_free(Job *job) =20 bs->job =3D NULL; block_job_remove_all_bdrv(bjob); - blk_remove_aio_context_notifier(bjob->blk, - block_job_attached_aio_context, - block_job_detach_aio_context, bjob); blk_unref(bjob->blk); error_free(bjob->blocker); } =20 -static void block_job_attached_aio_context(AioContext *new_context, - void *opaque) -{ - BlockJob *job =3D opaque; - const JobDriver *drv =3D job->job.driver; - BlockJobDriver *bjdrv =3D container_of(drv, BlockJobDriver, job_driver= ); - - job->job.aio_context =3D new_context; - if (bjdrv->attached_aio_context) { - bjdrv->attached_aio_context(job, new_context); - } - - job_resume(&job->job); -} - void block_job_drain(Job *job) { BlockJob *bjob =3D container_of(job, BlockJob, job); @@ -126,23 +104,6 @@ void block_job_drain(Job *job) } } =20 -static void block_job_detach_aio_context(void *opaque) -{ - BlockJob *job =3D opaque; - - /* In case the job terminates during aio_poll()... */ - job_ref(&job->job); - - job_pause(&job->job); - - while (!job->job.paused && !job_is_completed(&job->job)) { - job_drain(&job->job); - } - - job->job.aio_context =3D NULL; - job_unref(&job->job); -} - static char *child_job_get_parent_desc(BdrvChild *c) { BlockJob *job =3D c->opaque; @@ -212,6 +173,8 @@ static void child_job_set_aio_ctx(BdrvChild *c, AioCont= ext *ctx, *ignore =3D g_slist_prepend(*ignore, sibling); bdrv_set_aio_context_ignore(sibling->bs, ctx, ignore); } + + job->job.aio_context =3D ctx; } =20 static const BdrvChildRole child_job =3D { @@ -471,8 +434,6 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, =20 bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); =20 - blk_add_aio_context_notifier(blk, block_job_attached_aio_context, - block_job_detach_aio_context, job); blk_set_allow_aio_context_change(blk, true); =20 /* Only set speed when necessary to avoid NotSupported error */ --=20 2.20.1