[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/15] throttle: Check current timers before updating
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 02/15] throttle: Check current timers before updating any_timer_armed[] |
Date: |
Wed, 24 Jun 2015 16:27:53 +0100 |
From: Alberto Garcia <address@hidden>
Calling throttle_group_config() cancels all timers from a particular
BlockDriverState, so any_timer_armed[] should be updated accordingly.
However, with the current code it may happen that a timer is armed in
a different BlockDriverState from the same group, so any_timer_armed[]
would be set to false in a situation where there is still a timer
armed.
The consequence is that we might end up with two timers armed. This
should not have any noticeable impact however, since all accesses to
the ThrottleGroup are protected by a lock, and the situation would
become normal again shortly thereafter as soon as all timers have been
fired.
The correct way to solve this is to check that we're actually
cancelling a timer before updating any_timer_armed[].
Signed-off-by: Alberto Garcia <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/throttle-groups.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index efc462f..1abc6fc 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -324,9 +324,14 @@ void throttle_group_config(BlockDriverState *bs,
ThrottleConfig *cfg)
ThrottleState *ts = bs->throttle_state;
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
qemu_mutex_lock(&tg->lock);
- throttle_config(ts, tt, cfg);
/* throttle_config() cancels the timers */
- tg->any_timer_armed[0] = tg->any_timer_armed[1] = false;
+ if (timer_pending(tt->timers[0])) {
+ tg->any_timer_armed[0] = false;
+ }
+ if (timer_pending(tt->timers[1])) {
+ tg->any_timer_armed[1] = false;
+ }
+ throttle_config(ts, tt, cfg);
qemu_mutex_unlock(&tg->lock);
}
--
2.4.3
- [Qemu-devel] [PULL 00/15] Block patches, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 02/15] throttle: Check current timers before updating any_timer_armed[],
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 01/15] block: Let bdrv_drain_all() to call aio_poll() for each AioContext, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 03/15] block-backend: Introduce blk_drain(), Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 04/15] virtio-blk: Use blk_drain() to drain IO requests, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 05/15] util/hbitmap: Add an API to reset all set bits in hbitmap, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 07/15] nvme: Fix memleak in nvme_dma_read_prp, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 06/15] vvfat: add a label option, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 08/15] block: Use bdrv_is_sg() everywhere, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 09/15] Fix migration in case of scsi-generic, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 10/15] raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT, Stefan Hajnoczi, 2015/06/24
- [Qemu-devel] [PULL 11/15] raw-posix: Use DPRINTF for DEBUG_FLOPPY, Stefan Hajnoczi, 2015/06/24