]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Clear up index and last setting in single entry tree
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 3 Apr 2023 15:59:40 +0000 (11:59 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 27 Apr 2023 01:40:55 +0000 (21:40 -0400)
When there is a single entry tree (range of 0-0 pointing to an entry),
then ensure the limit is either 0-0 or 1-oo, depending on where the user
walks.  Ensure the correct node setting as well; either MAS_ROOT or
MAS_NONE.

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

index 7bf7446a625029e60947fb506473c58a17e4b1ff..8c98d1ab8744d684bcef73eeff4649f2115e0c17 100644 (file)
@@ -5099,24 +5099,25 @@ void *mas_walk(struct ma_state *mas)
 {
        void *entry;
 
+       if (mas_is_none(mas) || mas_is_paused(mas))
+               mas->node = MAS_START;
 retry:
        entry = mas_state_walk(mas);
-       if (mas_is_start(mas))
+       if (mas_is_start(mas)) {
                goto retry;
-
-       if (mas_is_ptr(mas)) {
+       } else if (mas_is_none(mas)) {
+               mas->index = 0;
+               mas->last = ULONG_MAX;
+       } else if (mas_is_ptr(mas)) {
                if (!mas->index) {
                        mas->last = 0;
-               } else {
-                       mas->index = 1;
-                       mas->last = ULONG_MAX;
+                       return mas_root(mas);
                }
-               return entry;
-       }
 
-       if (mas_is_none(mas)) {
-               mas->index = 0;
+               mas->index = 1;
                mas->last = ULONG_MAX;
+               mas->node = MAS_NONE;
+               return NULL;
        }
 
        return entry;