From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
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
Date: Thu, 24 Mar 2016 17:39:22 +0100 [thread overview]
Message-ID: <1458837566-108527-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1458837566-108527-1-git-send-email-pbonzini@redhat.com>
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 <pbonzini@redhat.com>
---
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,
--
1.8.3.1
next prev parent reply other threads:[~2016-03-24 16:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-24 16:39 [Qemu-devel] [PATCH v3 0/7] bdrv_flush_io_queue removal, shared LinuxAioState Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 1/7] block: Don't disable I/O throttling on sync requests Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 2/7] block: make bdrv_start_throttled_reqs return void Paolo Bonzini
2016-03-29 14:02 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-03-24 16:39 ` Paolo Bonzini [this message]
2016-03-29 14:14 ` [Qemu-devel] [Qemu-block] [PATCH 3/7] block: move restarting of throttled reqs to block/throttle-groups.c Alberto Garcia
2016-03-29 14:29 ` Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 4/7] block: introduce bdrv_no_throttling_begin/end Paolo Bonzini
2016-03-30 12:24 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-03-30 12:27 ` [Qemu-devel] " Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 5/7] block: plug whole tree at once, introduce bdrv_io_unplugged_begin/end Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 6/7] linux-aio: make it more type safe Paolo Bonzini
2016-03-24 16:39 ` [Qemu-devel] [PATCH 7/7] linux-aio: share one LinuxAioState within an AioContext Paolo Bonzini
2016-03-30 13:06 ` [Qemu-devel] [PATCH v3 0/7] bdrv_flush_io_queue removal, shared LinuxAioState Stefan Hajnoczi
2016-03-30 13:17 ` Paolo Bonzini
2016-04-06 18:19 ` Kevin Wolf
2016-04-06 18:28 ` Paolo Bonzini
2016-04-06 18:35 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458837566-108527-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).