cryptospore / rpms / qemu-kvm

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