maple_tree: replace data before marking dead in split and spanning store
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 4 Aug 2023 16:59:51 +0000 (12:59 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 21 Aug 2023 20:37:41 +0000 (13:37 -0700)
commit530f745c7620af288b71b3d667cb90f10df3defe
tree275a9a4f4491828b11d42c85d25ed29dfa0a5bd3
parent068bafcac0b89ee5b1616793231eb4b3dd41e3f0
maple_tree: replace data before marking dead in split and spanning store

Reorder the operations for split and spanning stores so that new data is
placed in the tree prior to marking the old data as dead.  This will limit
re-walks on dead data to just once instead of a retry loop.

The order of operations is as follows: Create the new data, put the new
data in place, mark the top node of the old data as dead.

Then repair parent links in the reused nodes through all levels of the
tree, following the new nodes downwards.  Finally walk the top dead node
looking for nodes that are no longer used, or subtrees that should be
destroyed (marked dead throughout then freed), follow the partially used
nodes downwards to discover other dead nodes and subtrees.

Link: https://lkml.kernel.org/r/20230804165951.2661157-7-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c