From: Wei Yang Date: Sat, 16 Nov 2024 01:48:04 +0000 (+0000) Subject: maple_tree: not possible to be a root node after loop X-Git-Tag: v6.14-rc1~77^2~282 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=f5bd418727856b104d6dcb43b144381c31250383;p=linux-2.6-block.git maple_tree: not possible to be a root node after loop 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 Reviewed-by: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Sidhartha Kumar Signed-off-by: Andrew Morton --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 57603524e2dd..3174234d77cb 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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; }