]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: reset mas->node to MAS_START in mas_next() if it's MAS_NONE
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 11 Nov 2020 18:36:14 +0000 (13:36 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 11 Nov 2020 18:36:14 +0000 (13:36 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index c2a6c9cfd28c1843a01b486b946666b37eb94d06..476c197d7adb286d253656797dbe8203f54e2f1a 100644 (file)
@@ -793,7 +793,7 @@ static inline void mas_ascend(struct ma_state *mas)
        a_enode = p_enode;
        if (mte_is_root(a_enode)) {
                a_node = mte_to_node(a_enode);
-               goto no_parent;
+               goto parent_is_root;
        }
 
        mas->node = p_enode;
@@ -812,6 +812,7 @@ ascend:
                max = mte_pivot(a_enode, a_slot);
        }
 
+parent_is_root:
 no_parent:
        if (ma_is_root(a_node)) {
                if (!set_min)
@@ -4529,6 +4530,9 @@ void *mas_next(struct ma_state *mas, unsigned long max)
 {
        unsigned long index = 0;
 
+       if (mas_is_none(mas))
+               mas->node = MAS_START;
+
        return _mas_next(mas, max, &index);
 }
 EXPORT_SYMBOL_GPL(mas_next);
@@ -4924,7 +4928,7 @@ void *mas_store(struct ma_state *mas, void *entry)
        if (mas_is_err(mas))
                return existing;
 
-       if (!mte_is_leaf(mas->node)) // gaps were updated
+       if (!mte_is_leaf(mas->node)) // spanning store occurred
                mas->node = MAS_START;
 
        return existing;
@@ -4951,7 +4955,7 @@ retry:
        if (mas_is_err(mas))
                return xa_err(mas->node);
 
-       if (!mte_is_leaf(mas->node)) // gaps were updated
+       if (!mte_is_leaf(mas->node)) // spanning store occurred
                mas->node = MAS_START;
 
        return 0;