]> www.infradead.org Git - users/jedix/linux-maple.git/commit
maple_tree: fix alloc node fail issue
authorJiazi Li <jqqlijiazi@gmail.com>
Wed, 26 Jun 2024 16:06:30 +0000 (12:06 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:08 +0000 (21:29 -0700)
commitfee3daffecb9af4738acedaec622c05889908832
treec1bdf8f8467808aeaef4e78e8db7935e641fee9e
parent427288973bfa631ea3e38139668eabc0179c702e
maple_tree: fix alloc node fail issue

In the following code, the second call to the mas_node_count will return
-ENOMEM:

mas_node_count(mas, MAPLE_ALLOC_SLOTS + 1);
mas_node_count(mas, MAPLE_ALLOC_SLOTS * 2 + 2);

This is because there may be some full maple_alloc node in current maple
state.  Use full maple_alloc node will make max_req equal to 0.  And it
leads to mt_alloc_bulk return 0.  As a result, mas_node_count set mas.node
to MA_ERROR(-ENOMEM).

Find a non-full maple_alloc node, and if necessary, use this non-full node
in the next while loop.

Link: https://lkml.kernel.org/r/20240626160631.3636515-1-Liam.Howlett@oracle.com
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Jiazi Li <jqqlijiazi@gmail.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c