From patchwork Thu Apr 7 16:33:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8774781 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B0E049FC82 for ; Thu, 7 Apr 2016 16:33:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0880D20251 for ; Thu, 7 Apr 2016 16:33:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37B81201EC for ; Thu, 7 Apr 2016 16:33:57 +0000 (UTC) Received: from localhost ([::1]:51284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoCsW-0001KO-Il for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Apr 2016 12:33:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoCsL-0001J7-1N for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoCsJ-0005js-VI for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:33:44 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoCsJ-0005jo-Kv; Thu, 07 Apr 2016 12:33:43 -0400 Received: by mail-wm0-x244.google.com with SMTP id l6so5684255wml.3; Thu, 07 Apr 2016 09:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=a76ERgHNQg8tBQdpnARmzuzs97gog5912DIwHlhQuZ0=; b=aaeL2LSAX4mZwQkuTHwzVzrLgGtjy7NnVfSMKBqD4Vawj/zqEWLkv9Kr9lVt1IMZD3 BlaKVcQFP57Cti5RBk9/zXGZ4fihqS4NFZ9LU5aY/9mzrSIKdPFpphP8NSyAFbFyGYUN 8AzVCi/mXA2v/mcN2vKqKEiasIWnLAJYVsbuJokNqsGn3aCtuNINca92s7Qg0D6KiVh2 7vzdnT54dF8CZvk8B0UK7gS+e1cRiXGifBlF8gn4sV/PMDjpdRcYa8DepwdgYmziKCvU P/aPcH646IlrQrUZRBqEa4o9Yv3I8T+LWiCzZkkHuBRM5G/Cewf3wk/7D0en1uwGVOQV hZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=a76ERgHNQg8tBQdpnARmzuzs97gog5912DIwHlhQuZ0=; b=d0uTnx8ac/G3PiaPQphkSht03G31DWBqInOGhEkTqJzQA1iAI61NVn0YOXkuRIFLFU a/BuSH+bkA+FS26cpQfVkIywAY9r0IpwYyxOirBGSM+Ul6RCMzFU9hQj3MJKqHDQj+dm GVKgZfgeZE2BMzvvAKrk6n6601BVO7w2twb0ec68sECPEBDYZXKuf87BHU+R1/8+nwJ+ XHTX3JLz8STVH3QSVCjN8vqx+oi8dY2SDHtC2Fa5JJT5JmSijNzjzKjYbBRe+QZKYQRA IkKmBpKB4mlAds48B/tXtPbd/WjqcEFcLuldaoGv4Wi8D8ogYTL+34q5DRGS5IJbx+pd kRDQ== X-Gm-Message-State: AD7BkJIfW0GCdjvlJnw+SXpp/uMUgSzM8EvqJXDSPINkK5yNjTmBPEzamYNhpSyBbZJXPA== X-Received: by 10.194.21.131 with SMTP id v3mr4538167wje.132.1460046822972; Thu, 07 Apr 2016 09:33:42 -0700 (PDT) Received: from 640k.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id hh8sm9218862wjc.42.2016.04.07.09.33.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 09:33:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Apr 2016 18:33:31 +0200 Message-Id: <1460046816-102846-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1460046816-102846-1-git-send-email-pbonzini@redhat.com> References: <1460046816-102846-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Cc: kwolf@redhat.com, berto@igalia.com, famz@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v4 3/8] block: move restarting of throttled reqs to block/throttle-groups.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want to remove throttled_reqs from block/io.c. This is the easy part---hide the handling of throttled_reqs during disable/enable of throttling within throttle-groups.c. Signed-off-by: Paolo Bonzini --- v1->v2: only restart first request after throttle_group_config v3->v4: remove aio_context_acquire/release, caller does it [Berto] block/io.c | 15 +-------------- block/throttle-groups.c | 14 ++++++++++++++ include/block/throttle-groups.h | 1 + 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/block/io.c b/block/io.c index 691baa6..9201b89 100644 --- a/block/io.c +++ b/block/io.c @@ -62,28 +62,15 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, void bdrv_set_io_limits(BlockDriverState *bs, ThrottleConfig *cfg) { - int i; - throttle_group_config(bs, cfg); - - for (i = 0; i < 2; i++) { - qemu_co_enter_next(&bs->throttled_reqs[i]); - } } static void bdrv_start_throttled_reqs(BlockDriverState *bs) { bool enabled = bs->io_limits_enabled; - int i; bs->io_limits_enabled = false; - - for (i = 0; i < 2; i++) { - while (qemu_co_enter_next(&bs->throttled_reqs[i])) { - ; - } - } - + throttle_group_restart_bs(bs); bs->io_limits_enabled = enabled; } diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 4920e09..b796f6b 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -313,6 +313,17 @@ void coroutine_fn throttle_group_co_io_limits_intercept(BlockDriverState *bs, qemu_mutex_unlock(&tg->lock); } +void throttle_group_restart_bs(BlockDriverState *bs) +{ + int i; + + for (i = 0; i < 2; i++) { + while (qemu_co_enter_next(&bs->throttled_reqs[i])) { + ; + } + } +} + /* Update the throttle configuration for a particular group. Similar * to throttle_config(), but guarantees atomicity within the * throttling group. @@ -335,6 +346,9 @@ void throttle_group_config(BlockDriverState *bs, ThrottleConfig *cfg) } throttle_config(ts, tt, cfg); qemu_mutex_unlock(&tg->lock); + + qemu_co_enter_next(&bs->throttled_reqs[0]); + qemu_co_enter_next(&bs->throttled_reqs[1]); } /* Get the throttle configuration from a particular group. Similar to diff --git a/include/block/throttle-groups.h b/include/block/throttle-groups.h index aba28f3..395f72d 100644 --- a/include/block/throttle-groups.h +++ b/include/block/throttle-groups.h @@ -38,6 +38,7 @@ void throttle_group_get_config(BlockDriverState *bs, ThrottleConfig *cfg); void throttle_group_register_bs(BlockDriverState *bs, const char *groupname); void throttle_group_unregister_bs(BlockDriverState *bs); +void throttle_group_restart_bs(BlockDriverState *bs); void coroutine_fn throttle_group_co_io_limits_intercept(BlockDriverState *bs, unsigned int bytes,