block: Remove ignore_bds_parents parameter from drain_begin/end.

ignore_bds_parents is now ignored during drain_begin and drain_end, so
we can just remove it there. It is still a valid optimisation for
drain_all in bdrv_drained_poll(), so leave it around there.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221118174110.55183-13-kwolf@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2022-11-18 18:41:07 +01:00
parent 57e05be343
commit a82a3bd135
3 changed files with 24 additions and 39 deletions

View File

@ -1226,7 +1226,7 @@ static char *bdrv_child_get_parent_desc(BdrvChild *c)
static void bdrv_child_cb_drained_begin(BdrvChild *child) static void bdrv_child_cb_drained_begin(BdrvChild *child)
{ {
BlockDriverState *bs = child->opaque; BlockDriverState *bs = child->opaque;
bdrv_do_drained_begin_quiesce(bs, NULL, false); bdrv_do_drained_begin_quiesce(bs, NULL);
} }
static bool bdrv_child_cb_drained_poll(BdrvChild *child) static bool bdrv_child_cb_drained_poll(BdrvChild *child)

View File

@ -45,13 +45,12 @@ static void bdrv_parent_cb_resize(BlockDriverState *bs);
static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int64_t bytes, BdrvRequestFlags flags); int64_t offset, int64_t bytes, BdrvRequestFlags flags);
static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore, static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore)
bool ignore_bds_parents)
{ {
BdrvChild *c, *next; BdrvChild *c, *next;
QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) { if (c == ignore) {
continue; continue;
} }
bdrv_parent_drained_begin_single(c, false); bdrv_parent_drained_begin_single(c, false);
@ -70,13 +69,12 @@ void bdrv_parent_drained_end_single(BdrvChild *c)
} }
} }
static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore, static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore)
bool ignore_bds_parents)
{ {
BdrvChild *c; BdrvChild *c;
QLIST_FOREACH(c, &bs->parents, next_parent) { QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) { if (c == ignore) {
continue; continue;
} }
bdrv_parent_drained_end_single(c); bdrv_parent_drained_end_single(c);
@ -242,7 +240,6 @@ typedef struct {
bool begin; bool begin;
bool poll; bool poll;
BdrvChild *parent; BdrvChild *parent;
bool ignore_bds_parents;
} BdrvCoDrainData; } BdrvCoDrainData;
/* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */ /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
@ -269,9 +266,8 @@ static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
} }
static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent, static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
bool ignore_bds_parents, bool poll); bool poll);
static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent, static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent);
bool ignore_bds_parents);
static void bdrv_co_drain_bh_cb(void *opaque) static void bdrv_co_drain_bh_cb(void *opaque)
{ {
@ -284,11 +280,10 @@ static void bdrv_co_drain_bh_cb(void *opaque)
aio_context_acquire(ctx); aio_context_acquire(ctx);
bdrv_dec_in_flight(bs); bdrv_dec_in_flight(bs);
if (data->begin) { if (data->begin) {
bdrv_do_drained_begin(bs, data->parent, data->ignore_bds_parents, bdrv_do_drained_begin(bs, data->parent, data->poll);
data->poll);
} else { } else {
assert(!data->poll); assert(!data->poll);
bdrv_do_drained_end(bs, data->parent, data->ignore_bds_parents); bdrv_do_drained_end(bs, data->parent);
} }
aio_context_release(ctx); aio_context_release(ctx);
} else { } else {
@ -303,7 +298,6 @@ static void bdrv_co_drain_bh_cb(void *opaque)
static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs, static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
bool begin, bool begin,
BdrvChild *parent, BdrvChild *parent,
bool ignore_bds_parents,
bool poll) bool poll)
{ {
BdrvCoDrainData data; BdrvCoDrainData data;
@ -321,7 +315,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
.done = false, .done = false,
.begin = begin, .begin = begin,
.parent = parent, .parent = parent,
.ignore_bds_parents = ignore_bds_parents,
.poll = poll, .poll = poll,
}; };
@ -353,8 +346,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
} }
} }
void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
BdrvChild *parent, bool ignore_bds_parents)
{ {
IO_OR_GS_CODE(); IO_OR_GS_CODE();
assert(!qemu_in_coroutine()); assert(!qemu_in_coroutine());
@ -362,9 +354,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
/* Stop things in parent-to-child order */ /* Stop things in parent-to-child order */
if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) { if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
aio_disable_external(bdrv_get_aio_context(bs)); aio_disable_external(bdrv_get_aio_context(bs));
bdrv_parent_drained_begin(bs, parent);
/* TODO Remove ignore_bds_parents, we don't consider it any more */
bdrv_parent_drained_begin(bs, parent, false);
if (bs->drv && bs->drv->bdrv_drain_begin) { if (bs->drv && bs->drv->bdrv_drain_begin) {
bs->drv->bdrv_drain_begin(bs); bs->drv->bdrv_drain_begin(bs);
} }
@ -372,14 +362,14 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
} }
static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent, static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
bool ignore_bds_parents, bool poll) bool poll)
{ {
if (qemu_in_coroutine()) { if (qemu_in_coroutine()) {
bdrv_co_yield_to_drain(bs, true, parent, ignore_bds_parents, poll); bdrv_co_yield_to_drain(bs, true, parent, poll);
return; return;
} }
bdrv_do_drained_begin_quiesce(bs, parent, ignore_bds_parents); bdrv_do_drained_begin_quiesce(bs, parent);
/* /*
* Wait for drained requests to finish. * Wait for drained requests to finish.
@ -391,7 +381,6 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
* nodes. * nodes.
*/ */
if (poll) { if (poll) {
assert(!ignore_bds_parents);
BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent)); BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
} }
} }
@ -399,20 +388,19 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
void bdrv_drained_begin(BlockDriverState *bs) void bdrv_drained_begin(BlockDriverState *bs)
{ {
IO_OR_GS_CODE(); IO_OR_GS_CODE();
bdrv_do_drained_begin(bs, NULL, false, true); bdrv_do_drained_begin(bs, NULL, true);
} }
/** /**
* This function does not poll, nor must any of its recursively called * This function does not poll, nor must any of its recursively called
* functions. * functions.
*/ */
static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent, static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
bool ignore_bds_parents)
{ {
int old_quiesce_counter; int old_quiesce_counter;
if (qemu_in_coroutine()) { if (qemu_in_coroutine()) {
bdrv_co_yield_to_drain(bs, false, parent, ignore_bds_parents, false); bdrv_co_yield_to_drain(bs, false, parent, false);
return; return;
} }
assert(bs->quiesce_counter > 0); assert(bs->quiesce_counter > 0);
@ -423,9 +411,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
if (bs->drv && bs->drv->bdrv_drain_end) { if (bs->drv && bs->drv->bdrv_drain_end) {
bs->drv->bdrv_drain_end(bs); bs->drv->bdrv_drain_end(bs);
} }
/* TODO Remove ignore_bds_parents, we don't consider it any more */ bdrv_parent_drained_end(bs, parent);
bdrv_parent_drained_end(bs, parent, false);
aio_enable_external(bdrv_get_aio_context(bs)); aio_enable_external(bdrv_get_aio_context(bs));
} }
} }
@ -433,7 +419,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
void bdrv_drained_end(BlockDriverState *bs) void bdrv_drained_end(BlockDriverState *bs)
{ {
IO_OR_GS_CODE(); IO_OR_GS_CODE();
bdrv_do_drained_end(bs, NULL, false); bdrv_do_drained_end(bs, NULL);
} }
void bdrv_drain(BlockDriverState *bs) void bdrv_drain(BlockDriverState *bs)
@ -491,7 +477,7 @@ void bdrv_drain_all_begin(void)
GLOBAL_STATE_CODE(); GLOBAL_STATE_CODE();
if (qemu_in_coroutine()) { if (qemu_in_coroutine()) {
bdrv_co_yield_to_drain(NULL, true, NULL, true, true); bdrv_co_yield_to_drain(NULL, true, NULL, true);
return; return;
} }
@ -516,7 +502,7 @@ void bdrv_drain_all_begin(void)
AioContext *aio_context = bdrv_get_aio_context(bs); AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context); aio_context_acquire(aio_context);
bdrv_do_drained_begin(bs, NULL, true, false); bdrv_do_drained_begin(bs, NULL, false);
aio_context_release(aio_context); aio_context_release(aio_context);
} }
@ -536,7 +522,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
g_assert(!bs->refcnt); g_assert(!bs->refcnt);
while (bs->quiesce_counter) { while (bs->quiesce_counter) {
bdrv_do_drained_end(bs, NULL, true); bdrv_do_drained_end(bs, NULL);
} }
} }
@ -558,7 +544,7 @@ void bdrv_drain_all_end(void)
AioContext *aio_context = bdrv_get_aio_context(bs); AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context); aio_context_acquire(aio_context);
bdrv_do_drained_end(bs, NULL, true); bdrv_do_drained_end(bs, NULL);
aio_context_release(aio_context); aio_context_release(aio_context);
} }

View File

@ -329,8 +329,7 @@ void bdrv_drained_begin(BlockDriverState *bs);
* Quiesces a BDS like bdrv_drained_begin(), but does not wait for already * Quiesces a BDS like bdrv_drained_begin(), but does not wait for already
* running requests to complete. * running requests to complete.
*/ */
void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent);
BdrvChild *parent, bool ignore_bds_parents);
/** /**
* bdrv_drained_end: * bdrv_drained_end: