|
|
ed5979 |
From 0dc7990533cef41e58579ee96315aca1fdc44ea1 Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
Date: Fri, 18 Nov 2022 18:41:07 +0100
|
|
|
ed5979 |
Subject: [PATCH 25/31] block: Remove ignore_bds_parents parameter from
|
|
|
ed5979 |
drain_begin/end.
|
|
|
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: [13/16] 1ed88d975a9569bffeb33ad847874417780ce408 (sgarzarella/qemu-kvm-c-9-s)
|
|
|
ed5979 |
|
|
|
ed5979 |
ignore_bds_parents is now ignored during drain_begin and drain_end, so
|
|
|
ed5979 |
we can just remove it there. It is still a valid optimisation for
|
|
|
ed5979 |
drain_all in bdrv_drained_poll(), so leave it around there.
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ed5979 |
Message-Id: <20221118174110.55183-13-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 a82a3bd135078d14f1bb4b5e50f51e77d3748270)
|
|
|
ed5979 |
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
block.c | 2 +-
|
|
|
ed5979 |
block/io.c | 58 +++++++++++++++-------------------------
|
|
|
ed5979 |
include/block/block-io.h | 3 +--
|
|
|
ed5979 |
3 files changed, 24 insertions(+), 39 deletions(-)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/block.c b/block.c
|
|
|
ed5979 |
index 5a583e260d..af31a94863 100644
|
|
|
ed5979 |
--- a/block.c
|
|
|
ed5979 |
+++ b/block.c
|
|
|
ed5979 |
@@ -1226,7 +1226,7 @@ static char *bdrv_child_get_parent_desc(BdrvChild *c)
|
|
|
ed5979 |
static void bdrv_child_cb_drained_begin(BdrvChild *child)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
BlockDriverState *bs = child->opaque;
|
|
|
ed5979 |
- bdrv_do_drained_begin_quiesce(bs, NULL, false);
|
|
|
ed5979 |
+ bdrv_do_drained_begin_quiesce(bs, NULL);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
static bool bdrv_child_cb_drained_poll(BdrvChild *child)
|
|
|
ed5979 |
diff --git a/block/io.c b/block/io.c
|
|
|
ed5979 |
index 87d6f22ec4..2e9503df6a 100644
|
|
|
ed5979 |
--- a/block/io.c
|
|
|
ed5979 |
+++ b/block/io.c
|
|
|
ed5979 |
@@ -45,13 +45,12 @@ static void bdrv_parent_cb_resize(BlockDriverState *bs);
|
|
|
ed5979 |
static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
|
|
|
ed5979 |
int64_t offset, int64_t bytes, BdrvRequestFlags flags);
|
|
|
ed5979 |
|
|
|
ed5979 |
-static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
|
|
|
ed5979 |
- bool ignore_bds_parents)
|
|
|
ed5979 |
+static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
BdrvChild *c, *next;
|
|
|
ed5979 |
|
|
|
ed5979 |
QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
|
|
|
ed5979 |
- if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) {
|
|
|
ed5979 |
+ if (c == ignore) {
|
|
|
ed5979 |
continue;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
bdrv_parent_drained_begin_single(c, false);
|
|
|
ed5979 |
@@ -70,13 +69,12 @@ void bdrv_parent_drained_end_single(BdrvChild *c)
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
|
|
|
ed5979 |
- bool ignore_bds_parents)
|
|
|
ed5979 |
+static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
BdrvChild *c;
|
|
|
ed5979 |
|
|
|
ed5979 |
QLIST_FOREACH(c, &bs->parents, next_parent) {
|
|
|
ed5979 |
- if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) {
|
|
|
ed5979 |
+ if (c == ignore) {
|
|
|
ed5979 |
continue;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
bdrv_parent_drained_end_single(c);
|
|
|
ed5979 |
@@ -242,7 +240,6 @@ typedef struct {
|
|
|
ed5979 |
bool begin;
|
|
|
ed5979 |
bool poll;
|
|
|
ed5979 |
BdrvChild *parent;
|
|
|
ed5979 |
- bool ignore_bds_parents;
|
|
|
ed5979 |
} BdrvCoDrainData;
|
|
|
ed5979 |
|
|
|
ed5979 |
/* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
|
|
|
ed5979 |
@@ -269,9 +266,8 @@ static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
- bool ignore_bds_parents, bool poll);
|
|
|
ed5979 |
-static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
- bool ignore_bds_parents);
|
|
|
ed5979 |
+ bool poll);
|
|
|
ed5979 |
+static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent);
|
|
|
ed5979 |
|
|
|
ed5979 |
static void bdrv_co_drain_bh_cb(void *opaque)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
@@ -284,11 +280,10 @@ static void bdrv_co_drain_bh_cb(void *opaque)
|
|
|
ed5979 |
aio_context_acquire(ctx);
|
|
|
ed5979 |
bdrv_dec_in_flight(bs);
|
|
|
ed5979 |
if (data->begin) {
|
|
|
ed5979 |
- bdrv_do_drained_begin(bs, data->parent, data->ignore_bds_parents,
|
|
|
ed5979 |
- data->poll);
|
|
|
ed5979 |
+ bdrv_do_drained_begin(bs, data->parent, data->poll);
|
|
|
ed5979 |
} else {
|
|
|
ed5979 |
assert(!data->poll);
|
|
|
ed5979 |
- bdrv_do_drained_end(bs, data->parent, data->ignore_bds_parents);
|
|
|
ed5979 |
+ bdrv_do_drained_end(bs, data->parent);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
aio_context_release(ctx);
|
|
|
ed5979 |
} else {
|
|
|
ed5979 |
@@ -303,7 +298,6 @@ static void bdrv_co_drain_bh_cb(void *opaque)
|
|
|
ed5979 |
static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
|
|
ed5979 |
bool begin,
|
|
|
ed5979 |
BdrvChild *parent,
|
|
|
ed5979 |
- bool ignore_bds_parents,
|
|
|
ed5979 |
bool poll)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
BdrvCoDrainData data;
|
|
|
ed5979 |
@@ -321,7 +315,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
|
|
ed5979 |
.done = false,
|
|
|
ed5979 |
.begin = begin,
|
|
|
ed5979 |
.parent = parent,
|
|
|
ed5979 |
- .ignore_bds_parents = ignore_bds_parents,
|
|
|
ed5979 |
.poll = poll,
|
|
|
ed5979 |
};
|
|
|
ed5979 |
|
|
|
ed5979 |
@@ -353,8 +346,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
|
|
|
ed5979 |
- BdrvChild *parent, bool ignore_bds_parents)
|
|
|
ed5979 |
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
IO_OR_GS_CODE();
|
|
|
ed5979 |
assert(!qemu_in_coroutine());
|
|
|
ed5979 |
@@ -362,9 +354,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
|
|
|
ed5979 |
/* Stop things in parent-to-child order */
|
|
|
ed5979 |
if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
|
|
|
ed5979 |
aio_disable_external(bdrv_get_aio_context(bs));
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- /* TODO Remove ignore_bds_parents, we don't consider it any more */
|
|
|
ed5979 |
- bdrv_parent_drained_begin(bs, parent, false);
|
|
|
ed5979 |
+ bdrv_parent_drained_begin(bs, parent);
|
|
|
ed5979 |
if (bs->drv && bs->drv->bdrv_drain_begin) {
|
|
|
ed5979 |
bs->drv->bdrv_drain_begin(bs);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
@@ -372,14 +362,14 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
- bool ignore_bds_parents, bool poll)
|
|
|
ed5979 |
+ bool poll)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
if (qemu_in_coroutine()) {
|
|
|
ed5979 |
- bdrv_co_yield_to_drain(bs, true, parent, ignore_bds_parents, poll);
|
|
|
ed5979 |
+ bdrv_co_yield_to_drain(bs, true, parent, poll);
|
|
|
ed5979 |
return;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
- bdrv_do_drained_begin_quiesce(bs, parent, ignore_bds_parents);
|
|
|
ed5979 |
+ bdrv_do_drained_begin_quiesce(bs, parent);
|
|
|
ed5979 |
|
|
|
ed5979 |
/*
|
|
|
ed5979 |
* Wait for drained requests to finish.
|
|
|
ed5979 |
@@ -391,7 +381,6 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
* nodes.
|
|
|
ed5979 |
*/
|
|
|
ed5979 |
if (poll) {
|
|
|
ed5979 |
- assert(!ignore_bds_parents);
|
|
|
ed5979 |
BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
@@ -399,20 +388,19 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
void bdrv_drained_begin(BlockDriverState *bs)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
IO_OR_GS_CODE();
|
|
|
ed5979 |
- bdrv_do_drained_begin(bs, NULL, false, true);
|
|
|
ed5979 |
+ bdrv_do_drained_begin(bs, NULL, true);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
/**
|
|
|
ed5979 |
* This function does not poll, nor must any of its recursively called
|
|
|
ed5979 |
* functions.
|
|
|
ed5979 |
*/
|
|
|
ed5979 |
-static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
- bool ignore_bds_parents)
|
|
|
ed5979 |
+static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
int old_quiesce_counter;
|
|
|
ed5979 |
|
|
|
ed5979 |
if (qemu_in_coroutine()) {
|
|
|
ed5979 |
- bdrv_co_yield_to_drain(bs, false, parent, ignore_bds_parents, false);
|
|
|
ed5979 |
+ bdrv_co_yield_to_drain(bs, false, parent, false);
|
|
|
ed5979 |
return;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
assert(bs->quiesce_counter > 0);
|
|
|
ed5979 |
@@ -423,9 +411,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
if (bs->drv && bs->drv->bdrv_drain_end) {
|
|
|
ed5979 |
bs->drv->bdrv_drain_end(bs);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
- /* TODO Remove ignore_bds_parents, we don't consider it any more */
|
|
|
ed5979 |
- bdrv_parent_drained_end(bs, parent, false);
|
|
|
ed5979 |
-
|
|
|
ed5979 |
+ bdrv_parent_drained_end(bs, parent);
|
|
|
ed5979 |
aio_enable_external(bdrv_get_aio_context(bs));
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
@@ -433,7 +419,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
|
|
|
ed5979 |
void bdrv_drained_end(BlockDriverState *bs)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
IO_OR_GS_CODE();
|
|
|
ed5979 |
- bdrv_do_drained_end(bs, NULL, false);
|
|
|
ed5979 |
+ bdrv_do_drained_end(bs, NULL);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
void bdrv_drain(BlockDriverState *bs)
|
|
|
ed5979 |
@@ -491,7 +477,7 @@ void bdrv_drain_all_begin(void)
|
|
|
ed5979 |
GLOBAL_STATE_CODE();
|
|
|
ed5979 |
|
|
|
ed5979 |
if (qemu_in_coroutine()) {
|
|
|
ed5979 |
- bdrv_co_yield_to_drain(NULL, true, NULL, true, true);
|
|
|
ed5979 |
+ bdrv_co_yield_to_drain(NULL, true, NULL, true);
|
|
|
ed5979 |
return;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
@@ -516,7 +502,7 @@ void bdrv_drain_all_begin(void)
|
|
|
ed5979 |
AioContext *aio_context = bdrv_get_aio_context(bs);
|
|
|
ed5979 |
|
|
|
ed5979 |
aio_context_acquire(aio_context);
|
|
|
ed5979 |
- bdrv_do_drained_begin(bs, NULL, true, false);
|
|
|
ed5979 |
+ bdrv_do_drained_begin(bs, NULL, false);
|
|
|
ed5979 |
aio_context_release(aio_context);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
@@ -536,7 +522,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
|
|
|
ed5979 |
g_assert(!bs->refcnt);
|
|
|
ed5979 |
|
|
|
ed5979 |
while (bs->quiesce_counter) {
|
|
|
ed5979 |
- bdrv_do_drained_end(bs, NULL, true);
|
|
|
ed5979 |
+ bdrv_do_drained_end(bs, NULL);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
@@ -558,7 +544,7 @@ void bdrv_drain_all_end(void)
|
|
|
ed5979 |
AioContext *aio_context = bdrv_get_aio_context(bs);
|
|
|
ed5979 |
|
|
|
ed5979 |
aio_context_acquire(aio_context);
|
|
|
ed5979 |
- bdrv_do_drained_end(bs, NULL, true);
|
|
|
ed5979 |
+ bdrv_do_drained_end(bs, NULL);
|
|
|
ed5979 |
aio_context_release(aio_context);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/include/block/block-io.h b/include/block/block-io.h
|
|
|
ed5979 |
index 9c36a16a1f..8f5e75756a 100644
|
|
|
ed5979 |
--- a/include/block/block-io.h
|
|
|
ed5979 |
+++ b/include/block/block-io.h
|
|
|
ed5979 |
@@ -329,8 +329,7 @@ void bdrv_drained_begin(BlockDriverState *bs);
|
|
|
ed5979 |
* Quiesces a BDS like bdrv_drained_begin(), but does not wait for already
|
|
|
ed5979 |
* running requests to complete.
|
|
|
ed5979 |
*/
|
|
|
ed5979 |
-void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
|
|
|
ed5979 |
- BdrvChild *parent, bool ignore_bds_parents);
|
|
|
ed5979 |
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent);
|
|
|
ed5979 |
|
|
|
ed5979 |
/**
|
|
|
ed5979 |
* bdrv_drained_end:
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.31.1
|
|
|
ed5979 |
|