]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Detect dead nodes in mas_start()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 24 Nov 2022 15:48:23 +0000 (10:48 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 28 Nov 2022 20:18:33 +0000 (15:18 -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 R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 6bf865c7204174ffa60636c63fab22523a51d9dd..c5bbd2a072288f08e473bd44e4dd7d4d38b70cc5 100644 (file)
@@ -1365,11 +1365,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;
                }