summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2015-11-04 15:15:35 +0200
committerKevin Wolf <kwolf@redhat.com>2015-11-11 16:25:47 +0100
commit5ac724184c286b367525035eabf4b8bb4a386c54 (patch)
tree0d57e21604578d35bf7c64574450b8cace77115c /block
parent62547b8a1c04daf30f50e3db362ade53e22bf222 (diff)
downloadhqemu-5ac724184c286b367525035eabf4b8bb4a386c54.zip
hqemu-5ac724184c286b367525035eabf4b8bb4a386c54.tar.gz
throttle: Check for pending requests in throttle_group_unregister_bs()
throttle_group_unregister_bs() removes a BlockDriverState from its throttling group and destroys the timers. This means that there must be no pending throttled requests at that point (because it would be impossible to complete them), so the caller has to drain them first. At the moment throttle_group_unregister_bs() is only called from bdrv_io_limits_disable(), which already takes care of draining the requests, so there's nothing to worry about, but this patch makes this invariant explicit in the documentation and adds the relevant assertions. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/throttle-groups.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index 3419af7..13b5baa 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -437,6 +437,9 @@ void throttle_group_register_bs(BlockDriverState *bs, const char *groupname)
* list, destroying the timers and setting the throttle_state pointer
* to NULL.
*
+ * The BlockDriverState must not have pending throttled requests, so
+ * the caller has to drain them first.
+ *
* The group will be destroyed if it's empty after this operation.
*
* @bs: the BlockDriverState to remove
@@ -446,6 +449,10 @@ void throttle_group_unregister_bs(BlockDriverState *bs)
ThrottleGroup *tg = container_of(bs->throttle_state, ThrottleGroup, ts);
int i;
+ assert(bs->pending_reqs[0] == 0 && bs->pending_reqs[1] == 0);
+ assert(qemu_co_queue_empty(&bs->throttled_reqs[0]));
+ assert(qemu_co_queue_empty(&bs->throttled_reqs[1]));
+
qemu_mutex_lock(&tg->lock);
for (i = 0; i < 2; i++) {
if (tg->tokens[i] == bs) {
OpenPOWER on IntegriCloud