sync mm-stable with mm-hotfixes-stable to pick up depended-upon changes
[linux-block.git] / lib / maple_tree.c
index dc1f45b1628d1bccfebcf68651cc452b8290f1ff..d30815cbab8089f8c4af25abee8913da0a16f8a1 100644 (file)
@@ -5475,6 +5475,17 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
 
        mas_wr_end_piv(&wr_mas);
        node_size = mas_wr_new_end(&wr_mas);
+
+       /* Slot store, does not require additional nodes */
+       if (node_size == wr_mas.node_end) {
+               /* reuse node */
+               if (!mt_in_rcu(mas->tree))
+                       return 0;
+               /* shifting boundary */
+               if (wr_mas.offset_end - mas->offset == 1)
+                       return 0;
+       }
+
        if (node_size >= mt_slots[wr_mas.type]) {
                /* Split, worst case for now. */
                request = 1 + mas_mt_height(mas) * 2;