diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2017-09-23 14:14:11 +0300 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-10-13 12:38:41 +0100 |
commit | b867eaa17b3940760f51134e409cb0580dd3dde3 (patch) | |
tree | 41c1321f73f59bca876f1aa35ada26e86b546840 /block | |
parent | f8ea8dacf0de636e2c0f13b90c0d75db97dc9b44 (diff) | |
download | qemu-b867eaa17b3940760f51134e409cb0580dd3dde3.zip qemu-b867eaa17b3940760f51134e409cb0580dd3dde3.tar.gz qemu-b867eaa17b3940760f51134e409cb0580dd3dde3.tar.bz2 |
block/throttle.c: add bdrv_co_drain_begin/end callbacks
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/throttle.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/block/throttle.c b/block/throttle.c index 5bca763..833175a 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -197,6 +197,21 @@ static bool throttle_recurse_is_first_non_filter(BlockDriverState *bs, return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); } +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); + } +} + +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); +} + static BlockDriver bdrv_throttle = { .format_name = "throttle", .protocol_name = "throttle", @@ -226,6 +241,9 @@ static BlockDriver bdrv_throttle = { .bdrv_reopen_abort = throttle_reopen_abort, .bdrv_co_get_block_status = bdrv_co_get_block_status_from_file, + .bdrv_co_drain_begin = throttle_co_drain_begin, + .bdrv_co_drain_end = throttle_co_drain_end, + .is_filter = true, }; |