Skip to contentSkip to conversation

throttle-groups: update tg->any_timer_armed[] on detach

PATCH Superseded Stefan Hajnoczi 4 participants 5 messages Sep 19, 2017 – Sep 25, 2017 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 6ba992c8d7..2bfd03faa0 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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
---
 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
#2 lore raw
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!

#3 lore raw
In reply to Stefan Hajnoczi
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...
---
 block/throttle-groups.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
block/throttle-groups.c +2 -0
index 6ba992c8d7..2bfd03faa0 100644
@@ -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

#4 lore raw
In reply to Stefan Hajnoczi

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...

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
index 6ba992c8d7..2bfd03faa0 100644
@@ -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