mtree_unlock(mt);
}
-int mas_entry_cnt(struct ma_state *mas, unsigned long nr_leaves);
+int mas_entry_count(struct ma_state *mas, unsigned long nr_leaves);
void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max);
void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max,
#include <trace/events/maple_tree.h>
#define MA_ROOT_PARENT 1
+#define MAPLE_NODE_MAX MAPLE_NODE_MASK
+
#define ma_parent_ptr(x) ((struct maple_pnode *)(x))
#define ma_mnode_ptr(x) ((struct maple_node *)(x))
#define ma_enode_ptr(x) ((struct maple_enode *)(x))
return mas->alloc;
}
-int mas_entry_cnt(struct ma_state *mas, unsigned long nr_entries) {
+int mas_entry_count(struct ma_state *mas, unsigned long nr_entries) {
int nonleaf_cap = MAPLE_ARANGE64_SLOTS - 1;
- int nr_leaves;
+ int nr_nodes;
if (!mt_is_alloc(mas->tree))
nonleaf_cap = MAPLE_RANGE64_SLOTS - 1;
- nr_leaves = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS);
- mas_node_cnt(mas, nr_leaves + DIV_ROUND_UP(nr_leaves, nonleaf_cap));
+ nr_nodes = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS); // leaves
+ nr_nodes += DIV_ROUND_UP(nr_nodes, nonleaf_cap);
+ mas_node_cnt(mas, min(nr_nodes, (int)MAPLE_NODE_MAX));
if (!mas_is_err(mas))
return 0;
return xa_err(mas->node);