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