_maple_insert cannot return MAS_START and does not need to allocate any
memory ever. _maple_setup_insert is the only function that would
request a restart due to no memory. _maple_setup_insert can either do
this by a split or by expanding root.
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
if (ms->tree->root == NULL) {
ms->tree->root = entry;
return 0;
- } else {
- return -EEXIST;
}
}
spin_lock(&ms.tree->lock);
retry:
walked = _maple_setup_insert(&ms);
- if (walked == MAS_START)
- goto retry;
+ if (walked == MAS_START) {
+ if (__maple_nomem(&ms, gfp))
+ goto retry;
+ }
if (walked != NULL)
goto already_exists;
ret = _maple_insert(&ms, entry);
- if (ret == -ENOMEM) {
- if (__maple_nomem(&ms, gfp))
- goto retry;
- }
already_exists:
spin_unlock(&ms.tree->lock);