Blame SOURCES/kvm-block-Don-t-poll-in-parent-drain-callbacks.patch

1bdc94
From 72f0fcad0938bba82537e78753e242d53f3f2583 Mon Sep 17 00:00:00 2001
1bdc94
From: Kevin Wolf <kwolf@redhat.com>
1bdc94
Date: Fri, 14 Sep 2018 10:55:10 +0200
1bdc94
Subject: [PATCH 19/49] block: Don't poll in parent drain callbacks
1bdc94
1bdc94
RH-Author: Kevin Wolf <kwolf@redhat.com>
1bdc94
Message-id: <20180914105540.18077-13-kwolf@redhat.com>
1bdc94
Patchwork-id: 82164
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 12/42] block: Don't poll in parent drain callbacks
1bdc94
Bugzilla: 1601212
1bdc94
RH-Acked-by: John Snow <jsnow@redhat.com>
1bdc94
RH-Acked-by: Max Reitz <mreitz@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
1bdc94
bdrv_do_drained_begin() is only safe if we have a single
1bdc94
BDRV_POLL_WHILE() after quiescing all affected nodes. We cannot allow
1bdc94
that parent callbacks introduce a nested polling loop that could cause
1bdc94
graph changes while we're traversing the graph.
1bdc94
1bdc94
Split off bdrv_do_drained_begin_quiesce(), which only quiesces a single
1bdc94
node without waiting for its requests to complete. These requests will
1bdc94
be waited for in the BDRV_POLL_WHILE() call down the call chain.
1bdc94
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
(cherry picked from commit dcf94a23b1add0f856db51e9ff5ba0774e096076)
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 block.c               |  2 +-
1bdc94
 block/io.c            | 24 ++++++++++++++++--------
1bdc94
 include/block/block.h |  9 +++++++++
1bdc94
 3 files changed, 26 insertions(+), 9 deletions(-)
1bdc94
1bdc94
diff --git a/block.c b/block.c
1bdc94
index 9afaf26..5a50de6 100644
1bdc94
--- a/block.c
1bdc94
+++ b/block.c
1bdc94
@@ -818,7 +818,7 @@ static char *bdrv_child_get_parent_desc(BdrvChild *c)
1bdc94
 static void bdrv_child_cb_drained_begin(BdrvChild *child)
1bdc94
 {
1bdc94
     BlockDriverState *bs = child->opaque;
1bdc94
-    bdrv_drained_begin(bs);
1bdc94
+    bdrv_do_drained_begin_quiesce(bs, NULL);
1bdc94
 }
1bdc94
 
1bdc94
 static bool bdrv_child_cb_drained_poll(BdrvChild *child)
1bdc94
diff --git a/block/io.c b/block/io.c
1bdc94
index 442ded1..9c41ff9 100644
1bdc94
--- a/block/io.c
1bdc94
+++ b/block/io.c
1bdc94
@@ -285,15 +285,10 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
1bdc94
     assert(data.done);
1bdc94
 }
1bdc94
 
1bdc94
-void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
1bdc94
-                           BdrvChild *parent, bool poll)
1bdc94
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
1bdc94
+                                   BdrvChild *parent)
1bdc94
 {
1bdc94
-    BdrvChild *child, *next;
1bdc94
-
1bdc94
-    if (qemu_in_coroutine()) {
1bdc94
-        bdrv_co_yield_to_drain(bs, true, recursive, parent, poll);
1bdc94
-        return;
1bdc94
-    }
1bdc94
+    assert(!qemu_in_coroutine());
1bdc94
 
1bdc94
     /* Stop things in parent-to-child order */
1bdc94
     if (atomic_fetch_inc(&bs->quiesce_counter) == 0) {
1bdc94
@@ -302,6 +297,19 @@ void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
1bdc94
 
1bdc94
     bdrv_parent_drained_begin(bs, parent);
1bdc94
     bdrv_drain_invoke(bs, true);
1bdc94
+}
1bdc94
+
1bdc94
+static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
1bdc94
+                                  BdrvChild *parent, bool poll)
1bdc94
+{
1bdc94
+    BdrvChild *child, *next;
1bdc94
+
1bdc94
+    if (qemu_in_coroutine()) {
1bdc94
+        bdrv_co_yield_to_drain(bs, true, recursive, parent, poll);
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    bdrv_do_drained_begin_quiesce(bs, parent);
1bdc94
 
1bdc94
     if (recursive) {
1bdc94
         bs->recursive_quiesce_counter++;
1bdc94
diff --git a/include/block/block.h b/include/block/block.h
1bdc94
index 2bbea7c..43f29b5 100644
1bdc94
--- a/include/block/block.h
1bdc94
+++ b/include/block/block.h
1bdc94
@@ -619,6 +619,15 @@ bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
1bdc94
 void bdrv_drained_begin(BlockDriverState *bs);
1bdc94
 
1bdc94
 /**
1bdc94
+ * bdrv_do_drained_begin_quiesce:
1bdc94
+ *
1bdc94
+ * Quiesces a BDS like bdrv_drained_begin(), but does not wait for already
1bdc94
+ * running requests to complete.
1bdc94
+ */
1bdc94
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
1bdc94
+                                   BdrvChild *parent);
1bdc94
+
1bdc94
+/**
1bdc94
  * Like bdrv_drained_begin, but recursively begins a quiesced section for
1bdc94
  * exclusive access to all child nodes as well.
1bdc94
  */
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94