stream: Replace subtree drain with a single node drain
commit92140b9f3f07d80e2c27edcc6e32f392be2135e6
authorKevin Wolf <kwolf@redhat.com>
Fri, 18 Nov 2022 17:41:04 +0000 (18 18:41 +0100)
committerKevin Wolf <kwolf@redhat.com>
Thu, 15 Dec 2022 15:07:42 +0000 (15 16:07 +0100)
tree932219b1b6b4bf6fd7a37da4c8f20e647fdb2016
parent631086deefc32690ee56efed1c5b891dec31ae37
stream: Replace subtree drain with a single node drain

The subtree drain was introduced in commit b1e1af394d9 as a way to avoid
graph changes between finding the base node and changing the block graph
as necessary on completion of the image streaming job.

The block graph could change between these two points because
bdrv_set_backing_hd() first drains the parent node, which involved
polling and can do anything.

Subtree draining was an imperfect way to make this less likely (because
with it, fewer callbacks are called during this window). Everyone agreed
that it's not really the right solution, and it was only committed as a
stopgap solution.

This replaces the subtree drain with a solution that simply drains the
parent node before we try to find the base node, and then call a version
of bdrv_set_backing_hd() that doesn't drain, but just asserts that the
parent node is already drained.

This way, any graph changes caused by draining happen before we start
looking at the graph and things stay consistent between finding the base
node and changing the graph.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221118174110.55183-10-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block/stream.c
include/block/block-global-state.h