#define MAPLE_SPARSE16_SLOTS 24 /* 248 bytes */
#define MAPLE_SPARSE9_SLOTS 27 /* 256 bytes */
#define MAPLE_SPARSE6_SLOTS 30 /* 256 bytes */
+#define MA_NODE_PER_PAGE 16
#else
#define MAPLE_NODE_SLOTS 15 /* 128 bytes including ->parent */
#define MAPLE_RANGE64_SLOTS 8 /* 128 bytes */
#define MAPLE_SPARSE16_SLOTS 12 /* 128 bytes */
#define MAPLE_SPARSE9_SLOTS 13 /* 127 bytes */
#define MAPLE_SPARSE6_SLOTS 14 /* 128 bytes */
+#define MA_NODE_PER_PAGE 32
#endif // End NODE256
#else
#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))
-#undef XA_RETRY_ENTRY
-#undef XA_SKIP_ENTRY
-#undef XA_DELETED_ENTRY
static struct kmem_cache *maple_node_cache;
const struct maple_node *mn, unsigned char slot,
enum maple_type type, struct maple_tree *mtree)
{
+
switch (type) {
case maple_range_64:
case maple_leaf_64:
static inline void mas_dup_alloc(struct ma_state *mas, int *node_cnt)
{
- int alloc_cnt = min(*node_cnt, 127);
+ int alloc_cnt = min(*node_cnt, MA_NODE_PER_PAGE);
/* Allocate nodes for new tree. Maximum will be 16 ** height */
*node_cnt -= alloc_cnt;
mas_node_cnt(mas, alloc_cnt);
struct ma_state *mas,
int *node_cnt)
{
+ if (xa_is_node(mas->tree->ma_root))
+ goto dup_children;
+
if (mas->alloc)
goto allocated;
mte_to_node(mas->node)->parent = ma_parent_ptr(
((unsigned long)mas->tree | MA_ROOT_PARENT));
rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
+
+dup_children:
if (!mte_is_leaf(oldmas->node)) {
mas_dup_children(mas, node_cnt);
+ if (mas_is_err(mas))
+ return;
mas_adopt_children(mas, mas->node);
}
}