]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Move idx-- and add a few comments
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Nov 2018 21:12:16 +0000 (16:12 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Nov 2018 21:12:16 +0000 (16:12 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 2429cff638073b26d4ce81c4b851bf763b09024b..b79c39645baf5b6b81c144f3f85cb9e4726b2c7d 100644 (file)
@@ -167,7 +167,7 @@ static void *_maple_walk(struct maple_state *ms)
        /* Outside this nodes range, it doesn't exist. */
        if (ms->min > ms->index ||
            ms->max < ms->index)
-               return entry;
+               return entry; // FIXME: Retry?
 
        if (ms->node == NULL)
                return entry;
@@ -197,6 +197,7 @@ static void *_maple_walk(struct maple_state *ms)
 static inline int _count_node_64(struct maple_state *ms) {
        int i;
        struct maple_node_64 mn64 = _maple_to_node(ms->node)->map64;
+
        for (i = 0; i < MAPLE_NODE64_MAX_PIVOT; i++) {
                if (mn64.pivot[i] == 0)
                        break;
@@ -389,9 +390,9 @@ static inline int _maple_insert_64(struct maple_state *ms, void *entry)
        idx = p_here + shift;
        mn64->pivot[idx] = ms->end + 1;
        rcu_assign_pointer(mn64->slot[idx], entry);
-       idx--;
 
        if (shift > 0) {
+               idx--;
                mn64->pivot[idx] = ms->index;
                rcu_assign_pointer(mn64->slot[idx], NULL);
        }
@@ -460,6 +461,7 @@ static void *_maple_insert_walk(struct maple_state *ms)
                ms->node = entry;
                _maple_update_limits(ms);
                if(_maple_is_node_4(ms)) {
+                       /* FIXME: What about range inserts on a node4? */
                        entry = _maple_walk_4(ms);
                        /* end of the line.. */
                        continue;
@@ -473,7 +475,7 @@ static void *_maple_insert_walk(struct maple_state *ms)
                         */
                        if (ret == -ENOMEM)
                                return maple_retry(ms);
-                       if (ret == -EINVAL) // FIXME..
+                       if (ret == -EINVAL) // FIXME: root expand on split may return an invalid insert.
                                return maple_retry(ms);
                        return NULL;
                }
@@ -488,7 +490,7 @@ static void *_maple_insert_walk(struct maple_state *ms)
                        struct maple_node *mn = ms->node;
                        entry = _maple_walk_64(ms, ms->end);
                        if (s_idx != ms->slot_idx || mn != ms->node)
-                               return mn;
+                               return mn; /* Return non-NULL for an insert fail */
                }
 
        } while(xa_is_internal(entry));