OSDN Git Service

block: Allow graph changes in bdrv_drain_all_begin/end sections
authorKevin Wolf <kwolf@redhat.com>
Wed, 28 Mar 2018 16:29:18 +0000 (18:29 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 18 Jun 2018 13:03:25 +0000 (15:03 +0200)
commit0f12264e7a41458179ad10276a7c33c72024861a
tree653cbbecadd1bb2e6f9b8c220e5a72a1285e2dce
parent6cd5c9d7b2df93ef54144f170d4c908934a4767f
block: Allow graph changes in bdrv_drain_all_begin/end sections

bdrv_drain_all_*() used bdrv_next() to iterate over all root nodes and
did a subtree drain for each of them. This works fine as long as the
graph is static, but sadly, reality looks different.

If the graph changes so that root nodes are added or removed, we would
have to compensate for this. bdrv_next() returns each root node only
once even if it's the root node for multiple BlockBackends or for a
monitor-owned block driver tree, which would only complicate things.

The much easier and more obviously correct way is to fundamentally
change the way the functions work: Iterate over all BlockDriverStates,
no matter who owns them, and drain them individually. Compensation is
only necessary when a new BDS is created inside a drain_all section.
Removal of a BDS doesn't require any action because it's gone afterwards
anyway.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block/io.c
include/block/block.h
include/block/block_int.h