[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/12] block: Don't check throttled reqs in bdrv_req
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 12/12] block: Don't check throttled reqs in bdrv_requests_pending() |
Date: |
Tue, 22 Mar 2016 16:33:12 +0100 |
Checking whether there are throttled requests requires going to the
associated BlockBackend, which we want to avoid. All users of
bdrv_requests_pending() already call bdrv_flush_io_queue() first, which
restarts throttled requests. We just have to use the return value of
that callback (which tells us whether any requests have been restarted)
instead of ignoring it.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 22 ++++++++++------------
include/block/block.h | 2 +-
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/block/io.c b/block/io.c
index f6edab8..24bdd6c 100644
--- a/block/io.c
+++ b/block/io.c
@@ -153,17 +153,10 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs)
bool bdrv_requests_pending(BlockDriverState *bs)
{
BdrvChild *child;
- BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;
if (!QLIST_EMPTY(&bs->tracked_requests)) {
return true;
}
- if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {
- return true;
- }
- if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {
- return true;
- }
QLIST_FOREACH(child, &bs->children, next) {
if (bdrv_requests_pending(child->bs)) {
@@ -204,8 +197,8 @@ void bdrv_drain(BlockDriverState *bs)
bdrv_drain_recurse(bs);
while (busy) {
/* Keep iterating */
- bdrv_flush_io_queue(bs);
- busy = bdrv_requests_pending(bs);
+ busy = bdrv_flush_io_queue(bs);
+ busy |= bdrv_requests_pending(bs);
busy |= aio_poll(bdrv_get_aio_context(bs), busy);
}
}
@@ -254,7 +247,9 @@ void bdrv_drain_all(void)
aio_context_acquire(aio_context);
while ((bs = bdrv_next(bs))) {
if (aio_context == bdrv_get_aio_context(bs)) {
- bdrv_flush_io_queue(bs);
+ if (bdrv_flush_io_queue(bs)) {
+ busy = true;
+ }
if (bdrv_requests_pending(bs)) {
busy = true;
aio_poll(aio_context, busy);
@@ -2639,10 +2634,11 @@ void bdrv_io_unplug(BlockDriverState *bs)
}
}
-void bdrv_flush_io_queue(BlockDriverState *bs)
+bool bdrv_flush_io_queue(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
BdrvChild *c;
+ bool new_request = false;
if (drv && drv->bdrv_flush_io_queue) {
drv->bdrv_flush_io_queue(bs);
@@ -2652,9 +2648,11 @@ void bdrv_flush_io_queue(BlockDriverState *bs)
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c->role->drain_queue) {
- c->role->drain_queue(c);
+ new_request |= c->role->drain_queue(c);
}
}
+
+ return new_request;
}
void bdrv_drained_begin(BlockDriverState *bs)
diff --git a/include/block/block.h b/include/block/block.h
index 80ece12..46cee8e 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -513,7 +513,7 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry
*geo);
void bdrv_io_plug(BlockDriverState *bs);
void bdrv_io_unplug(BlockDriverState *bs);
-void bdrv_flush_io_queue(BlockDriverState *bs);
+bool bdrv_flush_io_queue(BlockDriverState *bs);
/**
* bdrv_drained_begin:
--
1.8.3.1
- [Qemu-devel] [PATCH 03/12] block: Introduce BlockBackendPublic, (continued)
- [Qemu-devel] [PATCH 03/12] block: Introduce BlockBackendPublic, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 04/12] block: throttle-groups: Use BlockBackend pointers internally, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 08/12] block: Move I/O throttling configuration functions to BlockBackend, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 11/12] block: Decouple throttling from BlockDriverState, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 05/12] block: Convert throttle_group_get_name() to BlockBackend, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 07/12] block: Move actual I/O throttling to BlockBackend, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 10/12] block: Drain throttling queue with BdrvChild callback, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 06/12] block: Move throttling fields from BDS to BB, Kevin Wolf, 2016/03/22
- [Qemu-devel] [PATCH 12/12] block: Don't check throttled reqs in bdrv_requests_pending(),
Kevin Wolf <=
- Re: [Qemu-devel] [PATCH 00/12] block: Move I/O throttling to BlockBackend, Paolo Bonzini, 2016/03/22