[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 4/9] throttle: Implement AioContext drain ops
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH RFC 4/9] throttle: Implement AioContext drain ops |
Date: |
Wed, 29 Nov 2017 22:49:51 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
block/throttle.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/block/throttle.c b/block/throttle.c
index 833175ac77..35b740e3de 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -70,6 +70,25 @@ fin:
return ret;
}
+static void throttle_drained_begin(void *opaque)
+{
+ BlockDriverState *bs = opaque;
+ ThrottleGroupMember *tgm = bs->opaque;
+
+ if (atomic_fetch_inc(&tgm->io_limits_disabled) == 0) {
+ throttle_group_restart_tgm(tgm);
+ }
+}
+
+static void throttle_drained_end(void *opaque)
+{
+ BlockDriverState *bs = opaque;
+ ThrottleGroupMember *tgm = bs->opaque;
+
+ assert(tgm->io_limits_disabled);
+ atomic_dec(&tgm->io_limits_disabled);
+}
+
static int throttle_open(BlockDriverState *bs, QDict *options,
int flags, Error **errp)
{
@@ -146,6 +165,9 @@ static int throttle_co_flush(BlockDriverState *bs)
static void throttle_detach_aio_context(BlockDriverState *bs)
{
ThrottleGroupMember *tgm = bs->opaque;
+ aio_context_del_drain_ops(bdrv_get_aio_context(bs),
+ throttle_drained_begin, throttle_drained_end,
+ bs);
throttle_group_detach_aio_context(tgm);
}
@@ -153,6 +175,9 @@ static void throttle_attach_aio_context(BlockDriverState
*bs,
AioContext *new_context)
{
ThrottleGroupMember *tgm = bs->opaque;
+ aio_context_add_drain_ops(new_context,
+ throttle_drained_begin, throttle_drained_end,
+ bs);
throttle_group_attach_aio_context(tgm, new_context);
}
@@ -199,17 +224,12 @@ static bool
throttle_recurse_is_first_non_filter(BlockDriverState *bs,
static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs)
{
- ThrottleGroupMember *tgm = bs->opaque;
- if (atomic_fetch_inc(&tgm->io_limits_disabled) == 0) {
- throttle_group_restart_tgm(tgm);
- }
+ throttle_drained_begin(bs);
}
static void coroutine_fn throttle_co_drain_end(BlockDriverState *bs)
{
- ThrottleGroupMember *tgm = bs->opaque;
- assert(tgm->io_limits_disabled);
- atomic_dec(&tgm->io_limits_disabled);
+ throttle_drained_end(bs);
}
static BlockDriver bdrv_throttle = {
--
2.14.3
- [Qemu-devel] [PATCH RFC 0/9] block: Rewrite block drain begin/end, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 1/9] block: Remove unused bdrv_requests_pending, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 2/9] aio: Add drain begin/end API to AioContext, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 3/9] blockjob: Implement AioContext drain ops, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 4/9] throttle: Implement AioContext drain ops,
Fam Zheng <=
- [Qemu-devel] [PATCH RFC 5/9] qed: Implement AioContext drain ops, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 6/9] block: Use aio_context_drained_begin in bdrv_set_aio_context, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 7/9] block: Switch to use AIO drained begin/end API, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 8/9] block: Drop old drained_{begin, end} callbacks, Fam Zheng, 2017/11/29
- [Qemu-devel] [PATCH RFC 9/9] blockjob: Drop unused functions, Fam Zheng, 2017/11/29
- Re: [Qemu-devel] [PATCH RFC 0/9] block: Rewrite block drain begin/end, Kevin Wolf, 2017/11/29