From nobody Wed Dec 17 05:38:43 2025 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507902722015199.0161517649334; Fri, 13 Oct 2017 06:52:02 -0700 (PDT) Received: from localhost ([::1]:50427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e30NU-0000hr-6P for importer@patchew.org; Fri, 13 Oct 2017 09:51:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e30LW-0007rn-Bc for qemu-devel@nongnu.org; Fri, 13 Oct 2017 09:49:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e30LT-0006X4-9F for qemu-devel@nongnu.org; Fri, 13 Oct 2017 09:49:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e30LT-0006Wa-1y for qemu-devel@nongnu.org; Fri, 13 Oct 2017 09:49:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 038E585541; Fri, 13 Oct 2017 13:49:46 +0000 (UTC) Received: from localhost (unknown [10.36.118.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB97A18EE7; Fri, 13 Oct 2017 13:49:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 038E585541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Fri, 13 Oct 2017 14:49:30 +0100 Message-Id: <20171013134930.20200-4-stefanha@redhat.com> In-Reply-To: <20171013134930.20200-1-stefanha@redhat.com> References: <20171013134930.20200-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 13 Oct 2017 13:49:46 +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] [PULL 3/3] block/throttle.c: add bdrv_co_drain_begin/end callbacks 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: Peter Maydell , Stefan Hajnoczi , Manos Pitsidianakis 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" From: Manos Pitsidianakis Reviewed-by: Stefan Hajnoczi Reviewed-by: Fam Zheng Signed-off-by: Manos Pitsidianakis Signed-off-by: Stefan Hajnoczi --- block/throttle.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/throttle.c b/block/throttle.c index 5bca76300f..833175ac77 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -197,6 +197,21 @@ static bool throttle_recurse_is_first_non_filter(Block= DriverState *bs, return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); } =20 +static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs) +{ + ThrottleGroupMember *tgm =3D bs->opaque; + if (atomic_fetch_inc(&tgm->io_limits_disabled) =3D=3D 0) { + throttle_group_restart_tgm(tgm); + } +} + +static void coroutine_fn throttle_co_drain_end(BlockDriverState *bs) +{ + ThrottleGroupMember *tgm =3D bs->opaque; + assert(tgm->io_limits_disabled); + atomic_dec(&tgm->io_limits_disabled); +} + static BlockDriver bdrv_throttle =3D { .format_name =3D "throttle", .protocol_name =3D "throttle", @@ -226,6 +241,9 @@ static BlockDriver bdrv_throttle =3D { .bdrv_reopen_abort =3D throttle_reopen_abort, .bdrv_co_get_block_status =3D bdrv_co_get_block_status_fro= m_file, =20 + .bdrv_co_drain_begin =3D throttle_co_drain_begin, + .bdrv_co_drain_end =3D throttle_co_drain_end, + .is_filter =3D true, }; =20 --=20 2.13.6