From nobody Sun Apr 28 23:44:36 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1511460013304112.26572455337691; Thu, 23 Nov 2017 10:00:13 -0800 (PST) Received: from localhost ([::1]:45539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHvn4-00088o-9x for importer@patchew.org; Thu, 23 Nov 2017 12:59:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHvlh-0007Tg-Eq for qemu-devel@nongnu.org; Thu, 23 Nov 2017 12:58:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHvlg-0007Gw-Az for qemu-devel@nongnu.org; Thu, 23 Nov 2017 12:58:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eHvlH-0006ue-KA; Thu, 23 Nov 2017 12:58:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE5E15FD69; Thu, 23 Nov 2017 17:58:06 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-37.pek2.redhat.com [10.72.12.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C407862679; Thu, 23 Nov 2017 17:58:03 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 24 Nov 2017 01:57:47 +0800 Message-Id: <20171123175747.2309-2-famz@redhat.com> In-Reply-To: <20171123175747.2309-1-famz@redhat.com> References: <20171123175747.2309-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Nov 2017 17:58:06 +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 1/1] block: Don't poll for drain end 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only drained_begin cares about in flight requests are processed, there is no need to do BDRV_POLL_WHILE() if begin=3D=3Dfalse, because all that need to be done is recursively invoking children's callbacks. Signed-off-by: Fam Zheng Tested-by: John Snow --- block/io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index 4fdf93a014..55256c130b 100644 --- a/block/io.c +++ b/block/io.c @@ -192,13 +192,15 @@ static void bdrv_drain_invoke(BlockDriverState *bs, b= ool begin) static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin) { BdrvChild *child, *tmp; - bool waited; + bool waited =3D false; =20 /* Ensure any pending metadata writes are submitted to bs->file. */ bdrv_drain_invoke(bs, begin); =20 - /* Wait for drained requests to finish */ - waited =3D BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0); + if (begin) { + /* Wait for drained requests to finish */ + waited =3D BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0); + } =20 QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) { BlockDriverState *bs =3D child->bs; --=20 2.14.3