block: improve should_update_child
commit2f30b7c377fa9a7dfbaf6eed56a07be7953e509e
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Sat, 23 Feb 2019 19:20:39 +0000 (23 22:20 +0300)
committerKevin Wolf <kwolf@redhat.com>
Mon, 25 Feb 2019 14:03:19 +0000 (25 15:03 +0100)
tree009d1693be03dc02e18bd162ecd4151ad1ba5974
parent0dc165c1bd544cad4b58f9493d3f6f71fd41705e
block: improve should_update_child

As it already said in the comment, we don't want to create loops in
parent->child relations. So, when we try to append @to to @c, we should
check that @c is not in @to children subtree, and we should check it
recursively, not only the first level. The patch provides BFS-based
search, to check the relations.

This is needed for further fleecing-hook filter usage: we need to
append it to source, when the hook is already a parent of target, and
source may be in a backing chain of target (fleecing-scheme). So, on
appending, the hook should not became a child (direct or through
children subtree) of the target.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c