]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Detect dead nodes in mas_start()
authorLiam Howlett <Liam.Howlett@oracle.com>
Thu, 24 Nov 2022 15:48:23 +0000 (10:48 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 Jan 2023 20:55:35 +0000 (15:55 -0500)
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.

Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 4c7b1bcdd24cb0856aca21fa14cc7dd2b5744a37..548fed5212bcdd8f5ec5470a6b41ca4947811ca6 100644 (file)
@@ -1354,11 +1354,15 @@ static inline struct maple_enode *mas_start(struct ma_state *mas)
                mas->depth = 0;
                mas->offset = 0;
 
+retry:
                root = mas_root(mas);
                /* Tree with nodes */
                if (likely(xa_is_node(root))) {
                        mas->depth = 1;
                        mas->node = mte_safe_root(root);
+                       if (mte_dead_node(mas->node))
+                               goto retry;
+
                        return NULL;
                }