From patchwork Thu Mar 24 16:39:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 601688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3qWC1B1J6Pz9sD5 for ; Fri, 25 Mar 2016 03:43:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=tu5+42eK; dkim-atps=neutral Received: from localhost ([::1]:51833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8M0-0007eL-Ci for incoming@patchwork.ozlabs.org; Thu, 24 Mar 2016 12:43:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8IN-00017n-Rh for qemu-devel@nongnu.org; Thu, 24 Mar 2016 12:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj8II-0001Wh-4L for qemu-devel@nongnu.org; Thu, 24 Mar 2016 12:39:39 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8IH-0001WR-Lp; Thu, 24 Mar 2016 12:39:34 -0400 Received: by mail-wm0-x243.google.com with SMTP id p65so14177167wmp.1; Thu, 24 Mar 2016 09:39:33 -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=zGLTsNW//2gmim0EG8kQa8K+G5RbkqiN8fgjN5UD5o8=; b=tu5+42eK/gvbU5JqHFhY5eBwRJMgTU1FRdvh8hIWUjqBH9TuKbvAXIyhwbKKZh9Jjq L3HF2bRNqUR7Le15XiM80yTfeoYLHL9iil6gOjwTwIVrUDdxmyeFeirsiiMrD4wTfstK OsRTkfXzKGYwmA2Ocak7tkZubeauzf8fY0OaPV9QK8DzR3AROb94+xuCopqj34tWpM6x cTmyNHx26Yz6ikNS7srKFKkk+uZVU+k1gSHRXajYVX9Rt0qbaKmyuSBz7fdMqfRzVp/f YEh/a5VxpRq/f4Q2C8JUJo66NIuslaH76X0+AYCnumTKKvxiPQVPuMjxIu3v3NV8HcZx kEjA== 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=zGLTsNW//2gmim0EG8kQa8K+G5RbkqiN8fgjN5UD5o8=; b=fzwa5l0lPuefTdVuDdlfkk2sRki23Rpq7simO0TUGc9OlnU8nfWHV0osq0+RsQknLZ 1a9JjR/3S6EGXFeuZ9haydubwl1H+N7dwANUHwmOJqz23Px2m+udl7zSp3wc0i9Pl2SQ I54JBrKqtqU2ICOs0g7J+orUhOJ8fVCoqCrcvwlHio1uAAQ3yC/AvOFr493Jr9Z/iA2G gHGDZfT4ETVT8GXOHoZ9xXdUy5aKypwnN2LQ5/TUCAfo3Aok3qDBcxa19Ik2W0DJLh78 aaUK4pQcGHPAxuhYkUmqmp8Eulzy+9qTiyyNxGZhJ4be6DvtwJ6qpoJy91bEdVB0u7wl HFPw== X-Gm-Message-State: AD7BkJJxKxgn1SlFRnkb3UdhTb9/SVEAw0yhDwXUU28C0UiKsoJiyYFJlRTGCxWAIzRF+Q== X-Received: by 10.194.110.225 with SMTP id id1mr10740080wjb.45.1458837573087; Thu, 24 Mar 2016 09:39:33 -0700 (PDT) Received: from 640k.lan (94-39-161-17.adsl-ull.clienti.tiscali.it. [94.39.161.17]) by smtp.gmail.com with ESMTPSA id w125sm8508814wmw.18.2016.03.24.09.39.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Mar 2016 09:39:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 24 Mar 2016 17:39:22 +0100 Message-Id: <1458837566-108527-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1458837566-108527-1-git-send-email-pbonzini@redhat.com> References: <1458837566-108527-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::243 Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH 3/7] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- block/io.c | 15 +-------------- block/throttle-groups.c | 16 ++++++++++++++++ include/block/throttle-groups.h | 1 + 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/block/io.c b/block/io.c index 3703426..93696df 100644 --- a/block/io.c +++ b/block/io.c @@ -60,28 +60,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..9f52d2b 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,11 @@ void throttle_group_config(BlockDriverState *bs, ThrottleConfig *cfg) } throttle_config(ts, tt, cfg); qemu_mutex_unlock(&tg->lock); + + aio_context_acquire(bdrv_get_aio_context(bs)); + qemu_co_enter_next(&bs->throttled_reqs[0]); + qemu_co_enter_next(&bs->throttled_reqs[1]); + aio_context_release(bdrv_get_aio_context(bs)); } /* 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,