From: Liam R. Howlett Date: Fri, 30 Nov 2018 21:12:16 +0000 (-0500) Subject: maple_tree: Move idx-- and add a few comments X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=610d8ee0f18429f12f778e277c783642be2ade3f;p=users%2Fjedix%2Flinux-maple.git maple_tree: Move idx-- and add a few comments Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2429cff63807..b79c39645baf 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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));