maple_tree: Fix mas_spanning_rebalance() on insufficient data
Mike Rapoport contacted me off-list with a regression in running criu.
Periodic tests fail with an RCU stall during execution. Although rare,
it is possible to hit this with other uses so this patch should be
backported to fix the regression.
An insufficient node was causing an out-of-bounds access on the node in
mas_leaf_max_gap(). The cause was the faulty detection of the new node
being a root node when overwriting many entries at the end of the tree.
Fix the detection of a new root and ensure there is sufficient data
prior to entering the spanning rebalance loop.
Add a testcase to the maple tree test suite for this issue.
Cc: Andrei Vagin <avagin@gmail.com> Cc: usama.anjum@collabora.com Reported-by: Mike Rapoport <rppt@kernel.org> Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>