]> 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 Howlett <Liam.Howlett@oracle.com>
Thu, 24 Nov 2022 21:07:24 +0000 (16:07 -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.

Signed-off-by: Liam Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 2fdbfc73a85418a73a95156b67a6a430c00211dc..d72d1cba1b40d642fb27ef51fb5d22f78e658c04 100644 (file)
@@ -1360,11 +1360,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;
                }