mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
block: Drain source node in bdrv_replace_node()
Instead of just asserting that no requests are in flight in bdrv_replace_node(), which is a requirement that most callers ignore, we can just drain the source node right there. This fixes at least starting a commit job while I/O is active on the backing chain, but probably other callers, too. Having requests in flight on the target node isn't a problem because the target just gets new parents, but the call path of running requests isn't modified. So we can just drop this assertion without a replacement. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1711643 Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
e2a58ff493
commit
f871abd60f
1 changed files with 4 additions and 3 deletions
7
block.c
7
block.c
|
@ -4017,13 +4017,13 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
|
||||||
uint64_t perm = 0, shared = BLK_PERM_ALL;
|
uint64_t perm = 0, shared = BLK_PERM_ALL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(!atomic_read(&from->in_flight));
|
|
||||||
assert(!atomic_read(&to->in_flight));
|
|
||||||
|
|
||||||
/* Make sure that @from doesn't go away until we have successfully attached
|
/* Make sure that @from doesn't go away until we have successfully attached
|
||||||
* all of its parents to @to. */
|
* all of its parents to @to. */
|
||||||
bdrv_ref(from);
|
bdrv_ref(from);
|
||||||
|
|
||||||
|
assert(qemu_get_current_aio_context() == qemu_get_aio_context());
|
||||||
|
bdrv_drained_begin(from);
|
||||||
|
|
||||||
/* Put all parents into @list and calculate their cumulative permissions */
|
/* Put all parents into @list and calculate their cumulative permissions */
|
||||||
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
|
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
|
||||||
assert(c->bs == from);
|
assert(c->bs == from);
|
||||||
|
@ -4064,6 +4064,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_slist_free(list);
|
g_slist_free(list);
|
||||||
|
bdrv_drained_end(from);
|
||||||
bdrv_unref(from);
|
bdrv_unref(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue