|
|
ed5979 |
From 9a789d104a4a69031ad95d7fad6380ab21e82503 Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
Date: Fri, 18 Nov 2022 18:41:08 +0100
|
|
|
ed5979 |
Subject: [PATCH 26/31] block: Drop out of coroutine in
|
|
|
ed5979 |
bdrv_do_drained_begin_quiesce()
|
|
|
ed5979 |
|
|
|
ed5979 |
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ed5979 |
RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
|
|
|
ed5979 |
RH-Bugzilla: 2155112
|
|
|
ed5979 |
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
RH-Commit: [14/16] c9266663b822f703e55b6a07de98ceb56e69e924 (sgarzarella/qemu-kvm-c-9-s)
|
|
|
ed5979 |
|
|
|
ed5979 |
The next patch adds a parent drain to bdrv_attach_child_common(), which
|
|
|
ed5979 |
shouldn't be, but is currently called from coroutines in some cases (e.g.
|
|
|
ed5979 |
.bdrv_co_create implementations generally open new nodes). Therefore,
|
|
|
ed5979 |
the assertion that we're not in a coroutine doesn't hold true any more.
|
|
|
ed5979 |
|
|
|
ed5979 |
We could just remove the assertion because there is nothing in the
|
|
|
ed5979 |
function that should be in conflict with running in a coroutine, but
|
|
|
ed5979 |
just to be on the safe side, we can reverse the caller relationship
|
|
|
ed5979 |
between bdrv_do_drained_begin() and bdrv_do_drained_begin_quiesce() so
|
|
|
ed5979 |
that the latter also just drops out of coroutine context and we can
|
|
|
ed5979 |
still be certain in the future that any drain code doesn't run in
|
|
|
ed5979 |
coroutines.
|
|
|
ed5979 |
|
|
|
ed5979 |
As a nice side effect, the structure of bdrv_do_drained_begin() is now
|
|
|
ed5979 |
symmetrical with bdrv_do_drained_end().
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
Message-Id: <20221118174110.55183-14-kwolf@redhat.com>
|
|
|
ed5979 |
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
ed5979 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
|
|
ed5979 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
(cherry picked from commit 05c272ff0cf1b16cc3606f746182dd99b774f553)
|
|
|
ed5979 |
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
block/io.c | 25 ++++++++++++-------------
|
|
|
ed5979 |
1 file changed, 12 insertions(+), 13 deletions(-)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/block/io.c b/block/io.c
|
|
|
ed5979 |
index 2e9503df6a..5e9150d92c 100644
|
|
|
ed5979 |
--- a/block/io.c
|
|
|
ed5979 |
+++ b/block/io.c
|
|
|
ed5979 |
@@ -346,10 +346,15 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
|
|
|
ed5979 |
+static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
+ bool poll)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
IO_OR_GS_CODE();
|
|
|
ed5979 |
- assert(!qemu_in_coroutine());
|
|
|
ed5979 |
+
|
|
|
ed5979 |
+ if (qemu_in_coroutine()) {
|
|
|
ed5979 |
+ bdrv_co_yield_to_drain(bs, true, parent, poll);
|
|
|
ed5979 |
+ return;
|
|
|
ed5979 |
+ }
|
|
|
ed5979 |
|
|
|
ed5979 |
/* Stop things in parent-to-child order */
|
|
|
ed5979 |
if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
|
|
|
ed5979 |
@@ -359,17 +364,6 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
|
|
|
ed5979 |
bs->drv->bdrv_drain_begin(bs);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
-}
|
|
|
ed5979 |
-
|
|
|
ed5979 |
-static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
- bool poll)
|
|
|
ed5979 |
-{
|
|
|
ed5979 |
- if (qemu_in_coroutine()) {
|
|
|
ed5979 |
- bdrv_co_yield_to_drain(bs, true, parent, poll);
|
|
|
ed5979 |
- return;
|
|
|
ed5979 |
- }
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- bdrv_do_drained_begin_quiesce(bs, parent);
|
|
|
ed5979 |
|
|
|
ed5979 |
/*
|
|
|
ed5979 |
* Wait for drained requests to finish.
|
|
|
ed5979 |
@@ -385,6 +379,11 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
|
|
|
ed5979 |
+{
|
|
|
ed5979 |
+ bdrv_do_drained_begin(bs, parent, false);
|
|
|
ed5979 |
+}
|
|
|
ed5979 |
+
|
|
|
ed5979 |
void bdrv_drained_begin(BlockDriverState *bs)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
IO_OR_GS_CODE();
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.31.1
|
|
|
ed5979 |
|