Skip to content

Commit a7b92d5

Browse files
howlettakpm00
authored andcommitted
maple_tree: detect dead nodes in mas_start()
When initially starting a search, the root node may already be in the process of being replaced in RCU mode. Detect and restart the walk if this is the case. This is necessary for RCU mode of the maple tree. Link: https://lkml.kernel.org/r/20230227173632.3292573-3-surenb@google.com Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Liam Howlett <Liam.Howlett@oracle.com> Signed-off-by: Suren Baghdasaryan <surenb@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 39d0bd8 commit a7b92d5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/maple_tree.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,12 +1360,16 @@ static inline struct maple_enode *mas_start(struct ma_state *mas)
13601360
mas->max = ULONG_MAX;
13611361
mas->depth = 0;
13621362

1363+
retry:
13631364
root = mas_root(mas);
13641365
/* Tree with nodes */
13651366
if (likely(xa_is_node(root))) {
13661367
mas->depth = 1;
13671368
mas->node = mte_safe_root(root);
13681369
mas->offset = 0;
1370+
if (mte_dead_node(mas->node))
1371+
goto retry;
1372+
13691373
return NULL;
13701374
}
13711375

0 commit comments

Comments
 (0)