[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/12] block: Move actual I/O throttling to BlockBac
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 07/12] block: Move actual I/O throttling to BlockBackend |
Date: |
Tue, 22 Mar 2016 16:33:07 +0100 |
Signed-off-by: Kevin Wolf <address@hidden>
---
block/block-backend.c | 10 ++++++++++
block/io.c | 10 ----------
block/throttle-groups.c | 5 ++---
include/block/throttle-groups.h | 2 +-
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 8e8dbb2..1567d8b 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -715,6 +715,11 @@ static int coroutine_fn blk_co_preadv(BlockBackend *blk,
int64_t offset,
return ret;
}
+ /* throttling disk I/O */
+ if (blk->public.io_limits_enabled) {
+ throttle_group_co_io_limits_intercept(blk, bytes, false);
+ }
+
return bdrv_co_do_preadv(blk_bs(blk), offset, bytes, qiov, flags);
}
@@ -729,6 +734,11 @@ static int coroutine_fn blk_co_pwritev(BlockBackend *blk,
int64_t offset,
return ret;
}
+ /* throttling disk I/O */
+ if (blk->public.io_limits_enabled) {
+ throttle_group_co_io_limits_intercept(blk, bytes, true);
+ }
+
if (!blk->enable_write_cache) {
flags |= BDRV_REQ_FUA;
}
diff --git a/block/io.c b/block/io.c
index bfafdfa..84370ae 100644
--- a/block/io.c
+++ b/block/io.c
@@ -943,11 +943,6 @@ int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
flags |= BDRV_REQ_COPY_ON_READ;
}
- /* throttling disk I/O */
- if (bs->blk && blk_get_public(bs->blk)->io_limits_enabled) {
- throttle_group_co_io_limits_intercept(bs, bytes, false);
- }
-
/* Align read if necessary by padding qiov */
if (offset & (align - 1)) {
head_buf = qemu_blockalign(bs, align);
@@ -1292,11 +1287,6 @@ int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
return ret;
}
- /* throttling disk I/O */
- if (bs->blk && blk_get_public(bs->blk)->io_limits_enabled) {
- throttle_group_co_io_limits_intercept(bs, bytes, true);
- }
-
/*
* Align write if necessary by performing a read-modify-write cycle.
* Pad qiov with the read parts and be sure to have a tracked request not
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index af74f76..46e888c 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -280,18 +280,17 @@ static void schedule_next_request(BlockBackend *blk, bool
is_write)
* if necessary, and schedule the next request using a round robin
* algorithm.
*
- * @bs: the current BlockDriverState
+ * @blk: the current BlockBackend
* @bytes: the number of bytes for this I/O
* @is_write: the type of operation (read/write)
*/
-void coroutine_fn throttle_group_co_io_limits_intercept(BlockDriverState *bs,
+void coroutine_fn throttle_group_co_io_limits_intercept(BlockBackend *blk,
unsigned int bytes,
bool is_write)
{
bool must_wait;
BlockBackend *token;
- BlockBackend *blk = bs->blk;
BlockBackendPublic *blkp = blk_get_public(blk);
ThrottleGroup *tg = container_of(blkp->throttle_state, ThrottleGroup, ts);
qemu_mutex_lock(&tg->lock);
diff --git a/include/block/throttle-groups.h b/include/block/throttle-groups.h
index 61e84f3..7019d04 100644
--- a/include/block/throttle-groups.h
+++ b/include/block/throttle-groups.h
@@ -39,7 +39,7 @@ void throttle_group_get_config(BlockDriverState *bs,
ThrottleConfig *cfg);
void throttle_group_register_blk(BlockBackend *blk, const char *groupname);
void throttle_group_unregister_blk(BlockBackend *blk);
-void coroutine_fn throttle_group_co_io_limits_intercept(BlockDriverState *bs,
+void coroutine_fn throttle_group_co_io_limits_intercept(BlockBackend *blk,
unsigned int bytes,
bool is_write);
--
1.8.3.1
- [Qemu-devel] [PATCH 09/12] block: Introduce BdrvChild.opaque, (continued)
[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 <=
[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, 2016/03/22
Re: [Qemu-devel] [PATCH 00/12] block: Move I/O throttling to BlockBackend, Paolo Bonzini, 2016/03/22