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

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