[PATCH 2/3] maple_tree: not possible to be a root node after loop
Liam R. Howlett
Liam.Howlett at oracle.com
Mon Nov 18 12:49:55 PST 2024
* Wei Yang <richard.weiyang at gmail.com> [241115 20:48]:
> 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.
Isn't this needed for the overflow case? That is, if there is a range
that ends at ULONG_MAX, then we will break from the loop on the offset
limit, but not check for root, return false, and continue to loop.
>
> This means the check for root node here is not necessary.
>
> Signed-off-by: Wei Yang <richard.weiyang at gmail.com>
> CC: Liam R. Howlett <Liam.Howlett at Oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes at oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar at oracle.com>
> ---
> lib/maple_tree.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 63dccd7b9474..ab235d0194f7 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -4891,7 +4891,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);
> @@ -4908,9 +4908,6 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size)
> }
> }
>
> - if (mte_is_root(mas->node))
> - found = true;
> -done:
> mas->offset = offset;
> return found;
> }
> --
> 2.34.1
>
More information about the maple-tree
mailing list