On 08.11.22 13:37, Kevin Wolf wrote:
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 <kw...@redhat.com>
---
  include/block/block-global-state.h |  3 +++
  block.c                            | 17 ++++++++++++++---
  block/stream.c                     | 20 ++++++++++----------
  3 files changed, 27 insertions(+), 13 deletions(-)

Reviewed-by: Hanna Reitz <hre...@redhat.com>


Reply via email to