From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, berto@igalia.com,
mreitz@redhat.com, eblake@redhat.com, stefanha@redhat.com,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 09/13] block: Drain throttling queue with BdrvChild callback
Date: Fri, 22 Apr 2016 19:42:38 +0200 [thread overview]
Message-ID: <1461346962-4676-10-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1461346962-4676-1-git-send-email-kwolf@redhat.com>
This removes the last part of I/O throttling from block/io.c and moves
it to the BlockBackend.
Instead of having knowledge about throttling inside io.c, we can call a
BdrvChild callback .drained_begin/end, which happens to drain the
throttled requests for BlockBackend parents.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/block-backend.c | 32 +++++++++++++++++++++++++++-----
block/io.c | 39 ++++++++++++++++++---------------------
include/block/block_int.h | 8 +++-----
3 files changed, 48 insertions(+), 31 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index b72a73d..73ff5e6 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -91,9 +91,14 @@ static void blk_root_inherit_options(int *child_flags, QDict *child_options,
/* We're not supposed to call this function for root nodes */
abort();
}
+static void blk_root_drained_begin(BdrvChild *child);
+static void blk_root_drained_end(BdrvChild *child);
static const BdrvChildRole child_root = {
- .inherit_options = blk_root_inherit_options,
+ .inherit_options = blk_root_inherit_options,
+
+ .drained_begin = blk_root_drained_begin,
+ .drained_end = blk_root_drained_end,
};
/*
@@ -836,9 +841,9 @@ int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
return ret;
}
- bdrv_no_throttling_begin(blk_bs(blk));
+ blk_root_drained_begin(blk->root);
ret = blk_read(blk, sector_num, buf, nb_sectors);
- bdrv_no_throttling_end(blk_bs(blk));
+ blk_root_drained_end(blk->root);
return ret;
}
@@ -1677,9 +1682,9 @@ void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg)
void blk_io_limits_disable(BlockBackend *blk)
{
assert(blk->public.throttle_state);
- bdrv_no_throttling_begin(blk_bs(blk));
+ bdrv_drained_begin(blk_bs(blk));
throttle_group_unregister_blk(blk);
- bdrv_no_throttling_end(blk_bs(blk));
+ bdrv_drained_end(blk_bs(blk));
}
/* should be called before bdrv_set_io_limits if a limit is set */
@@ -1705,3 +1710,20 @@ void blk_io_limits_update_group(BlockBackend *blk, const char *group)
blk_io_limits_disable(blk);
blk_io_limits_enable(blk, group);
}
+
+static void blk_root_drained_begin(BdrvChild *child)
+{
+ BlockBackend *blk = child->opaque;
+
+ if (blk->public.io_limits_disabled++ == 0) {
+ throttle_group_restart_blk(blk);
+ }
+}
+
+static void blk_root_drained_end(BdrvChild *child)
+{
+ BlockBackend *blk = child->opaque;
+
+ assert(blk->public.io_limits_disabled);
+ --blk->public.io_limits_disabled;
+}
diff --git a/block/io.c b/block/io.c
index b892fce..b239e97 100644
--- a/block/io.c
+++ b/block/io.c
@@ -27,7 +27,6 @@
#include "sysemu/block-backend.h"
#include "block/blockjob.h"
#include "block/block_int.h"
-#include "block/throttle-groups.h"
#include "qemu/cutils.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
@@ -58,28 +57,26 @@ static void coroutine_fn bdrv_co_do_rw(void *opaque);
static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, BdrvRequestFlags flags);
-void bdrv_no_throttling_begin(BlockDriverState *bs)
+static void bdrv_parent_drained_begin(BlockDriverState *bs)
{
- if (!bs->blk) {
- return;
- }
+ BdrvChild *c;
- if (blk_get_public(bs->blk)->io_limits_disabled++ == 0) {
- throttle_group_restart_blk(bs->blk);
+ QLIST_FOREACH(c, &bs->parents, next_parent) {
+ if (c->role->drained_begin) {
+ c->role->drained_begin(c);
+ }
}
}
-void bdrv_no_throttling_end(BlockDriverState *bs)
+static void bdrv_parent_drained_end(BlockDriverState *bs)
{
- BlockBackendPublic *blkp;
+ BdrvChild *c;
- if (!bs->blk) {
- return;
+ QLIST_FOREACH(c, &bs->parents, next_parent) {
+ if (c->role->drained_end) {
+ c->role->drained_end(c);
+ }
}
-
- blkp = blk_get_public(bs->blk);
- assert(blkp->io_limits_disabled);
- --blkp->io_limits_disabled;
}
void bdrv_setup_io_funcs(BlockDriver *bdrv)
@@ -278,17 +275,17 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
*/
void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
{
- bdrv_no_throttling_begin(bs);
+ bdrv_parent_drained_begin(bs);
bdrv_io_unplugged_begin(bs);
bdrv_drain_recurse(bs);
bdrv_co_yield_to_drain(bs);
bdrv_io_unplugged_end(bs);
- bdrv_no_throttling_end(bs);
+ bdrv_parent_drained_end(bs);
}
void bdrv_drain(BlockDriverState *bs)
{
- bdrv_no_throttling_begin(bs);
+ bdrv_parent_drained_begin(bs);
bdrv_io_unplugged_begin(bs);
bdrv_drain_recurse(bs);
if (qemu_in_coroutine()) {
@@ -297,7 +294,7 @@ void bdrv_drain(BlockDriverState *bs)
bdrv_drain_poll(bs);
}
bdrv_io_unplugged_end(bs);
- bdrv_no_throttling_end(bs);
+ bdrv_parent_drained_end(bs);
}
/*
@@ -320,7 +317,7 @@ void bdrv_drain_all(void)
if (bs->job) {
block_job_pause(bs->job);
}
- bdrv_no_throttling_begin(bs);
+ bdrv_parent_drained_begin(bs);
bdrv_io_unplugged_begin(bs);
bdrv_drain_recurse(bs);
aio_context_release(aio_context);
@@ -363,7 +360,7 @@ void bdrv_drain_all(void)
aio_context_acquire(aio_context);
bdrv_io_unplugged_end(bs);
- bdrv_no_throttling_end(bs);
+ bdrv_parent_drained_end(bs);
if (bs->job) {
block_job_resume(bs->job);
}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index ddadb7f..cfcdaec 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -361,6 +361,9 @@ typedef struct BdrvAioNotifier {
struct BdrvChildRole {
void (*inherit_options)(int *child_flags, QDict *child_options,
int parent_flags, QDict *parent_options);
+
+ void (*drained_begin)(BdrvChild *child);
+ void (*drained_end)(BdrvChild *child);
};
extern const BdrvChildRole child_file;
@@ -518,8 +521,6 @@ int get_tmp_filename(char *filename, int size);
BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
const char *filename);
-bool bdrv_start_throttled_reqs(BlockDriverState *bs);
-
/**
* bdrv_add_before_write_notifier:
@@ -702,9 +703,6 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const BdrvChildRole *child_role);
void bdrv_root_unref_child(BdrvChild *child);
-void bdrv_no_throttling_begin(BlockDriverState *bs);
-void bdrv_no_throttling_end(BlockDriverState *bs);
-
void blk_dev_change_media_cb(BlockBackend *blk, bool load);
bool blk_dev_has_removable_media(BlockBackend *blk);
bool blk_dev_has_tray(BlockBackend *blk);
--
1.8.3.1
next prev parent reply other threads:[~2016-04-22 17:43 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 17:42 [Qemu-devel] [PATCH v2 00/13] block: Move I/O throttling to BlockBackend Kevin Wolf
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 01/13] block: Make sure throttled BDSes always have a BB Kevin Wolf
2016-05-04 12:44 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 02/13] block: Introduce BlockBackendPublic Kevin Wolf
2016-05-04 12:45 ` Alberto Garcia
2016-05-04 14:23 ` Eric Blake
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 03/13] block: throttle-groups: Use BlockBackend pointers internally Kevin Wolf
2016-05-04 12:51 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 04/13] block: Convert throttle_group_get_name() to BlockBackend Kevin Wolf
2016-05-04 12:52 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 05/13] block: Move throttling fields from BDS to BB Kevin Wolf
2016-05-04 13:36 ` Alberto Garcia
2016-05-09 12:43 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-05-11 12:45 ` Kevin Wolf
2016-05-10 12:36 ` [Qemu-devel] " Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 06/13] block: Move actual I/O throttling to BlockBackend Kevin Wolf
2016-05-04 13:05 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 07/13] block: Move I/O throttling configuration functions " Kevin Wolf
2016-05-04 14:11 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 08/13] block: Introduce BdrvChild.opaque Kevin Wolf
2016-05-06 12:54 ` Alberto Garcia
2016-05-06 13:19 ` Kevin Wolf
2016-05-06 15:13 ` Alberto Garcia
2016-04-22 17:42 ` Kevin Wolf [this message]
2016-05-06 15:13 ` [Qemu-devel] [PATCH v2 09/13] block: Drain throttling queue with BdrvChild callback Alberto Garcia
2016-05-09 13:17 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-05-09 15:42 ` Kevin Wolf
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 10/13] block: Decouple throttling from BlockDriverState Kevin Wolf
2016-05-10 12:38 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 11/13] block: Remove bdrv_move_feature_fields() Kevin Wolf
2016-05-04 14:14 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 12/13] Revert "block: Forbid I/O throttling on nodes with multiple parents for 2.6" Kevin Wolf
2016-05-09 12:31 ` Alberto Garcia
2016-04-22 17:42 ` [Qemu-devel] [PATCH v2 13/13] block: Don't check throttled reqs in bdrv_requests_pending() Kevin Wolf
2016-05-10 12:20 ` Alberto Garcia
2016-05-11 12:35 ` Kevin Wolf
2016-04-29 10:01 ` [Qemu-devel] [PATCH v2 00/13] block: Move I/O throttling to BlockBackend Kevin Wolf
2016-04-29 11:57 ` Alberto Garcia
2016-05-09 13:21 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
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=1461346962-4676-10-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=berto@igalia.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.