#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))
mas_set_alloc_req(mas, 0);
if (!mas_allocated(mas) ||
- mas->alloc->node_count == MAPLE_NODE_SLOTS - 1) {
+ mas->alloc->node_count == MAPLE_NODE_SLOTS - 2) {
node = (struct maple_alloc *)mt_alloc_one(gfp);
if (!node)
goto nomem;
success = allocated = node->total;
while(requested) {
void **slots = (void**)&node->slot;
- unsigned int max = MAPLE_NODE_SLOTS - 1;
+ unsigned int max_off = MAPLE_NODE_SLOTS - 1;
if (node->slot[0]) {
- slots = (void**)&node->slot[node->node_count + 1];
- max -= node->node_count;
+ unsigned int offset = node->node_count + 1;
+ slots = (void**)&node->slot[offset];
+ max_off -= offset;
}
- count = min(requested, max);
+ count = min(requested, max_off);
count = mt_alloc_bulk(gfp, count, slots);
if (!count)
goto nomem;
+ node->node_count += count;
if (slots == (void**)&node->slot)
- node->node_count = count - 1; // zero indexed.
- else
- node->node_count += count;
+ node->node_count--; // zero indexed.
success += count;
nodep = &node->slot[0];
nr_nodes = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS); // leaves
nr_nodes += DIV_ROUND_UP(nr_nodes, nonleaf_cap);
- mas_node_count(mas, min(nr_nodes, (int)MAPLE_NODE_MAX));
+ mas_node_count(mas, nr_nodes);
if (!mas_is_err(mas))
return 0;