]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: mas_data_end starts at offset mt_min_slots now
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 23 Sep 2020 02:40:32 +0000 (22:40 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:08 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index ec1f782d2a6836b3021f97b0f93275438eba289c..66c539b4c815c8382abb137bddb9023ce3a40c09 100644 (file)
@@ -1024,15 +1024,23 @@ done:
  */
 static inline unsigned char mas_data_end(const struct ma_state *mas)
 {
-       unsigned char offset = 0;
        enum maple_type type = mte_node_type(mas->node);
+       unsigned char offset = mt_min_slots[type];
        unsigned long piv, *pivots = ma_pivots(mas_mn(mas), type);
 
-       while (offset < mt_slots[type]) {
-               piv = _mas_safe_pivot(mas, pivots, offset, type);
-               if ((!piv && offset) || piv >= mas->max)
-                       break;
-               offset++;
+       if (pivots[offset]) {
+               while (offset < mt_slots[type]) {
+                       piv = _mas_safe_pivot(mas, pivots, offset, type);
+                       if ((!piv && offset) || piv >= mas->max)
+                               break;
+                       offset++;
+               }
+       } else {
+               offset--;
+               do {
+                       if (pivots[offset])
+                               break;
+               } while (--offset);
        }
 
        return offset;