lib/maple_tree: Fix expand root to correctly set up non-zero pivots.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 4 Dec 2018 17:25:17 +0000 (12:25 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 4 Dec 2018 17:25:17 +0000 (12:25 -0500)
When expanding the root node, be sure to only add a pivot at 0 if there
was a previous value, otherwise add a pivot for one less than the
pending insert.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index f7189062a38f5e30ead0e570da2d00c8435b3f8e..05c6b3d824363ad10a858ff834f68965715c986b 100644 (file)
@@ -269,8 +269,12 @@ static int _maple_root_expand(struct maple_state *ms)
         * rcu_assign is not necessary as readers are not able to access this
         * node.
         */
-       RCU_INIT_POINTER(mn->map64.slot[0], r_entry);
-       mn->map64.pivot[0] = 1;
+       if (r_entry != NULL) {
+               RCU_INIT_POINTER(mn->map64.slot[0], r_entry);
+               mn->map64.pivot[0] = 1;
+       } else {
+               mn->map64.pivot[0] = ms->index;
+       }
 
        ms->slot_idx = 1;