Don't shift; we'll lose the top two bits. Instead just OR in bit 1
to ensure this pointer is seen as a node pointer, and subtract off 2,
just like the XArray does for turning nodes into entries and vice versa.
Also don't return an entry from _maple_new_node(), return a node and let
the caller take care of turning it into an entry, if it needs an entry.
Also don't use GFP_NOWAIT in mtree_init().
Signed-off-by: Matthew Wilcox <willy@infradead.org>
return true;
return false;
}
+
static inline struct maple_node *_maple_to_node(const void *entry)
{
- return (struct maple_node *)(xa_to_internal(entry));
+ return (struct maple_node *)((unsigned long)entry - 2);
+}
+
+static inline void *_maple_mk_node(const struct maple_node *node)
+{
+ return (void *)((unsigned long)node | 2);
}
static inline bool _maple_is_node_4(struct maple_state *ms) {
return false;
}
-static void *_maple_new_node(gfp_t gfp)
+static struct maple_node *_maple_new_node(gfp_t gfp)
{
struct maple_node *mn;
size_t size = sizeof(struct maple_node);
goto kmalloc_failed;
mn->map64.parent = NULL;
- mn = xa_mk_internal((unsigned long)mn);
kmalloc_failed:
return mn;
{
spin_lock_init(&mt->lock);
mt->flags = 0;
- mt->root = _maple_new_node(GFP_KERNEL | GFP_NOWAIT | __GFP_ZERO);
+ mt->root = _maple_mk_node(_maple_new_node(GFP_KERNEL | __GFP_ZERO));
mt->min = 0;
mt->max = ULONG_MAX;