]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
maple_tree: not possible to be a root node after loop
authorWei Yang <richard.weiyang@gmail.com>
Sat, 16 Nov 2024 01:48:04 +0000 (01:48 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 14 Jan 2025 06:40:39 +0000 (22:40 -0800)
Empty tree and single entry tree is handled else whether, so the maple
tree here must be a tree with nodes.

If the height is 1 and we found the gap, it will jump to *done* since it
is also a leaf.

If the height is more than one, and there may be an available range, we
will descend the tree, which is not root anymore.

If there is no available range, we will set error and return.

This means the check for root node here is not necessary.

Link: https://lkml.kernel.org/r/20241116014805.11547-3-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c

index 57603524e2dd5dbc9915adc99211fb872965fc0e..3174234d77cb9625cafa059b937bbb9a4f0de282 100644 (file)
@@ -4880,7 +4880,7 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size)
                if (gap >= size) {
                        if (ma_is_leaf(type)) {
                                found = true;
-                               goto done;
+                               break;
                        }
 
                        mas->node = mas_slot(mas, slots, offset);
@@ -4897,9 +4897,6 @@ next_slot:
                }
        }
 
-       if (mte_is_root(mas->node))
-               found = true;
-done:
        mas->offset = offset;
        return found;
 }