throttle-groups: update tg->any_timer_armed[] on detach
PATCH 1/1 throttle-groups: update tg->any_timer_armed[] on detach
Clear tg->any_timer_armed[] when throttling timers are destroy during AioContext attach/detach. Failure to do so causes throttling to hang because we believe the timer is already scheduled!
The following was broken at least since QEMU 2.10.0 with -drive iops=100:
$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 (qemu) stop (qemu) cont ...I/O is stuck...
--- block/throttle-groups.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
block/throttle-groups.c +13 -0
@@ -592,7 +592,20 @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,void throttle_group_detach_aio_context (ThrottleGroupMember *tgm) {ThrottleTimers *tt = &tgm->throttle_timers; +ThrottleGroup *tg =container_of (tgm->throttle_state, ThrottleGroup, ts); +throttle_timers_detach_aio_context (tt); + +/* Forget about these timers, they have been destroyed */ +qemu_mutex_lock (&tg->lock); +if (tg->tokens[0 ] == tgm) { + tg->any_timer_armed[0 ] = false; + } +if (tg->tokens[1 ] == tgm) { + tg->any_timer_armed[1 ] = false; + } +qemu_mutex_unlock (&tg->lock); + tgm->aio_context =NULL ; }
Signature · 1 line
2.13.5
Quoted 1 line · Stefan Hajnoczi
Clear tg->any_timer_armed[] when throttling timers are destroy during
s/destroy/destroyed/
Quoted 11 lines
AioContext attach/detach. Failure to do so causes throttling to hang because we believe the timer is already scheduled!
The following was broken at least since QEMU 2.10.0 with -drive iops=100:
$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 (qemu) stop (qemu) cont ...I/O is stuck...
Quoted 6 lines
Reported-by Yongxue Hong <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- block/throttle-groups.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 4 lines · Eric Blake
Quoted 1 line · Stefan Hajnoczi
Clear tg->any_timer_armed[] when throttling timers are destroy during
s/destroy/destroyed/
All your base are belong to us!
Quoted 29 lines · Stefan Hajnoczi
Clear tg->any_timer_armed[] when throttling timers are destroy during AioContext attach/detach. Failure to do so causes throttling to hang because we believe the timer is already scheduled!
The following was broken at least since QEMU 2.10.0 with -drive iops=100:
$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 (qemu) stop (qemu) cont ...I/O is stuck...Reported-by Yongxue Hong <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- block/throttle-groups.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)block/throttle-groups.c +2
-0@@ -592,7 +592,20 @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,void throttle_group_detach_aio_context (ThrottleGroupMember *tgm) {ThrottleTimers *tt = &tgm->throttle_timers; +ThrottleGroup *tg =container_of (tgm->throttle_state, ThrottleGroup, ts); +throttle_timers_detach_aio_context (tt);
block/throttle-groups.c void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, · line 607
Quoted 10 lines
block/throttle-groups.c +10
-0+ +/* Forget about these timers, they have been destroyed */ +qemu_mutex_lock (&tg->lock); +if (tg->tokens[0 ] == tgm) { + tg->any_timer_armed[0 ] = false; + } +if (tg->tokens[1 ] == tgm) { + tg->any_timer_armed[1 ] = false; + } +qemu_mutex_unlock (&tg->lock);
I think I'd rather check the timers directly using timer_pending().
See https://github.com/qemu/qemu/blob/dbe824cc5/block/throttle-groups.c#L426
Berto
Quoting Stefan Hajnoczi (2017-09-19 10:50:25)
Quoted 7 lines
Clear tg->any_timer_armed[] when throttling timers are destroy during AioContext attach/detach. Failure to do so causes throttling to hang because we believe the timer is already scheduled!
The following was broken at least since QEMU 2.10.0 with -drive iops=100:
Quoted 7 lines
$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 (qemu) stop (qemu) cont ...I/O is stuck...Reported-by Yongxue Hong <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
FYI: this patch has been tagged for stable 2.10.1, but is not yet upstream. Patch freeze for 2.10.1 is September 27th.
Quoted 33 lines
--- block/throttle-groups.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)block/throttle-groups.c +13
-0@@ -592,7 +592,20 @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,void throttle_group_detach_aio_context (ThrottleGroupMember *tgm) {ThrottleTimers *tt = &tgm->throttle_timers; +ThrottleGroup *tg =container_of (tgm->throttle_state, ThrottleGroup, ts); +throttle_timers_detach_aio_context (tt); + +/* Forget about these timers, they have been destroyed */ +qemu_mutex_lock (&tg->lock); +if (tg->tokens[0 ] == tgm) { + tg->any_timer_armed[0 ] = false; + } +if (tg->tokens[1 ] == tgm) { + tg->any_timer_armed[1 ] = false; + } +qemu_mutex_unlock (&tg->lock); + tgm->aio_context =NULL ; }Signature · 1 line
2.13.5