]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix error in retry logic.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 7 Dec 2018 20:57:09 +0000 (15:57 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 7 Dec 2018 20:57:09 +0000 (15:57 -0500)
_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>
lib/maple_tree.c

index d7b605d609b93d529afcb3622401baf8cf6ad1bd..bf751db3f16035acf7b8c1335a2692d5cb8c7a17 100644 (file)
@@ -585,8 +585,6 @@ static inline int _maple_insert(struct maple_state *ms, void *entry)
                if (ms->tree->root == NULL) {
                        ms->tree->root = entry;
                        return 0;
-               } else {
-                       return -EEXIST;
                }
        }
 
@@ -721,16 +719,14 @@ int mtree_insert_range(struct maple_tree *mt, unsigned long start,
        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);