From nobody Mon Feb 9 09:08:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511967493292329.5886694115285; Wed, 29 Nov 2017 06:58:13 -0800 (PST) Received: from localhost ([::1]:43503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eK3oN-0003cC-HZ for importer@patchew.org; Wed, 29 Nov 2017 09:58:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eK3iR-0005vD-Tp for qemu-devel@nongnu.org; Wed, 29 Nov 2017 09:52:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eK3iR-0006FL-5z for qemu-devel@nongnu.org; Wed, 29 Nov 2017 09:52:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19003) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eK3iM-0006BE-MB; Wed, 29 Nov 2017 09:51:54 -0500 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 BE808C0008D4; Wed, 29 Nov 2017 14:51:53 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-98.pek2.redhat.com [10.72.12.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id C09C25C1AB; Wed, 29 Nov 2017 14:51:44 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 29 Nov 2017 22:49:52 +0800 Message-Id: <20171129144956.11409-6-famz@redhat.com> In-Reply-To: <20171129144956.11409-1-famz@redhat.com> References: <20171129144956.11409-1-famz@redhat.com> 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.31]); Wed, 29 Nov 2017 14:51:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RFC 5/9] qed: Implement AioContext drain ops 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, jcody@redhat.com, Max Reitz , Stefan Hajnoczi , pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- block/qed.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/block/qed.c b/block/qed.c index 821dcaa055..8ddaa31e7c 100644 --- a/block/qed.c +++ b/block/qed.c @@ -337,12 +337,33 @@ static void qed_cancel_need_check_timer(BDRVQEDState = *s) timer_del(s->need_check_timer); } =20 +static void bdrv_qed_drained_begin(void *opaque) +{ + BlockDriverState *bs =3D opaque; + BDRVQEDState *s =3D bs->opaque; + + /* Fire the timer immediately in order to start doing I/O as soon as t= he + * header is flushed. + */ + if (s->need_check_timer && timer_pending(s->need_check_timer)) { + qed_cancel_need_check_timer(s); + qed_need_check_timer_entry(s); + } +} + +static void bdrv_qed_drained_end(void *opaque) +{ +} + static void bdrv_qed_detach_aio_context(BlockDriverState *bs) { BDRVQEDState *s =3D bs->opaque; =20 qed_cancel_need_check_timer(s); timer_free(s->need_check_timer); + aio_context_del_drain_ops(bdrv_get_aio_context(bs), + bdrv_qed_drained_begin, bdrv_qed_drained_end, + bs); } =20 static void bdrv_qed_attach_aio_context(BlockDriverState *bs, @@ -356,19 +377,14 @@ static void bdrv_qed_attach_aio_context(BlockDriverSt= ate *bs, if (s->header.features & QED_F_NEED_CHECK) { qed_start_need_check_timer(s); } + aio_context_add_drain_ops(new_context, + bdrv_qed_drained_begin, bdrv_qed_drained_end, + bs); } =20 static void coroutine_fn bdrv_qed_co_drain_begin(BlockDriverState *bs) { - BDRVQEDState *s =3D bs->opaque; - - /* Fire the timer immediately in order to start doing I/O as soon as t= he - * header is flushed. - */ - if (s->need_check_timer && timer_pending(s->need_check_timer)) { - qed_cancel_need_check_timer(s); - qed_need_check_timer_entry(s); - } + bdrv_qed_drained_begin(bs); } =20 static void bdrv_qed_init_state(BlockDriverState *bs) --=20 2.14.3