From nobody Mon Nov 3 20:19:29 2025 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506000119107256.33380254296344; Thu, 21 Sep 2017 06:21:59 -0700 (PDT) Received: from localhost ([::1]:53682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv1QU-0007hj-7s for importer@patchew.org; Thu, 21 Sep 2017 09:21:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv1Mo-00057G-AA for qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dv1Mi-00046k-KX for qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:18:10 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:39075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv1Ma-00040F-AE; Thu, 21 Sep 2017 09:17:56 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v8LDHpSp083326 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2017 16:17:51 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Thu, 21 Sep 2017 16:17:07 +0300 Message-Id: <20170921131707.17364-4-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921131707.17364-1-el13635@mail.ntua.gr> References: <20170921131707.17364-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH v2 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: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , qemu-block , Max Reitz 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" Reviewed-by: Stefan Hajnoczi Signed-off-by: Manos Pitsidianakis Reviewed-by: Fam Zheng --- 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.11.0