[PATCH] maple_tree: fix alloc node fail issue
Jiazi Li
jqqlijiazi at gmail.com
Mon Jun 24 05:01:00 PDT 2024
In the following code, the second call to the mas_node_count will
return -ENOMEM:
mas_node_count(&maple_tree, 31);
mas_node_count(&maple_tree, 62);
This is because get a node with node_count is MAPLE_ALLOC_SLOTS in
while loop of mas_alloc_nodes. And this will result in max_req
is zero in next loop.
Signed-off-by: Jiazi Li <jiazi.li at transsion.com>
---
lib/maple_tree.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index aa3a5df15b8e..82c236972115 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1272,7 +1272,9 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
node->node_count += count;
allocated += count;
- node = node->slot[0];
+ do {
+ node = node->slot[0];
+ } while (unlikely(node->node_count == MAPLE_ALLOC_SLOTS));
requested -= count;
}
mas->alloc->total = allocated;
--
2.17.1
More information about the maple-tree
mailing list