Blame SOURCES/kvm-throttle-groups-forget-timer-and-schedule-next-TGM-o.patch

4a2fec
From ae4ca7d9cfb0033cf39971f1c59e9a20a80c9bee Mon Sep 17 00:00:00 2001
4a2fec
From: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Date: Fri, 17 Nov 2017 11:19:08 +0100
4a2fec
Subject: [PATCH 09/15] throttle-groups: forget timer and schedule next TGM on
4a2fec
 detach
4a2fec
4a2fec
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-id: <20171117111908.8815-10-stefanha@redhat.com>
4a2fec
Patchwork-id: 77744
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 9/9] throttle-groups: forget timer and schedule next TGM on detach
4a2fec
Bugzilla: 1492295
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
4a2fec
tg->any_timer_armed[] must be cleared when detaching pending timers from
4a2fec
the AioContext.  Failure to do so leads to hung I/O because it looks
4a2fec
like there are still timers pending when in fact they have been removed.
4a2fec
4a2fec
Other ThrottleGroupMembers might have requests pending too so it's
4a2fec
necessary to schedule the next TGM so it can set a timer.
4a2fec
4a2fec
This patch fixes hung I/O when QEMU is launched with drives that are in
4a2fec
the same throttling group:
4a2fec
4a2fec
  (guest)$ dd if=/dev/zero of=/dev/vdb oflag=direct bs=512 &
4a2fec
  (guest)$ dd if=/dev/zero of=/dev/vdc oflag=direct bs=512 &
4a2fec
  (qemu) stop
4a2fec
  (qemu) cont
4a2fec
  ...I/O is stuck...
4a2fec
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-id: 20171116112150.27607-1-stefanha@redhat.com
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
(cherry picked from commit 341e0b5658681f46680024cdbfc998717d85cc35)
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block/throttle-groups.c | 12 ++++++++++++
4a2fec
 1 file changed, 12 insertions(+)
4a2fec
4a2fec
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
4a2fec
index 44cc1e6..35c22ac 100644
4a2fec
--- a/block/throttle-groups.c
4a2fec
+++ b/block/throttle-groups.c
4a2fec
@@ -567,13 +567,25 @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,
4a2fec
 
4a2fec
 void throttle_group_detach_aio_context(ThrottleGroupMember *tgm)
4a2fec
 {
4a2fec
+    ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts);
4a2fec
     ThrottleTimers *tt = &tgm->throttle_timers;
4a2fec
+    int i;
4a2fec
 
4a2fec
     /* Requests must have been drained */
4a2fec
     assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0);
4a2fec
     assert(qemu_co_queue_empty(&tgm->throttled_reqs[0]));
4a2fec
     assert(qemu_co_queue_empty(&tgm->throttled_reqs[1]));
4a2fec
 
4a2fec
+    /* Kick off next ThrottleGroupMember, if necessary */
4a2fec
+    qemu_mutex_lock(&tg->lock);
4a2fec
+    for (i = 0; i < 2; i++) {
4a2fec
+        if (timer_pending(tt->timers[i])) {
4a2fec
+            tg->any_timer_armed[i] = false;
4a2fec
+            schedule_next_request(tgm, i);
4a2fec
+        }
4a2fec
+    }
4a2fec
+    qemu_mutex_unlock(&tg->lock);
4a2fec
+
4a2fec
     throttle_timers_detach_aio_context(tt);
4a2fec
     tgm->aio_context = NULL;
4a2fec
 }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec