]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix mas_for_each limits on index when searching for first entry in node
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 22 Oct 2020 18:46:13 +0000 (14:46 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:36 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index cd0d4a84015bfce4c06b73dd4e7b0f5337164a5f..f8f94474eced86f94d4d5c2bf01d38a4e9ece5c3 100644 (file)
@@ -1281,18 +1281,18 @@ static inline void mas_update_gap(struct ma_state *mas)
 }
 
 /*
- * mas_first_entry() - * Returns the pivot which points to the entry with the
- * lowest index.
+ * mas_first_entry() - Go the first leaf and find the first entry.
  *
  * @mas: the maple state.
  * @limit: the maximum index to check.
+ * Returns: The start of the pivot.
  */
 static inline unsigned long mas_first_entry(struct ma_state *mas,
                unsigned long limit)
 {
        void **slots, *entry;
        int offset = 0;
-       unsigned long pivot = mas->min;
+       unsigned long prev_piv = mas->min;
 
        while (!mte_is_leaf(mas->node)) {
                mas->max = mte_pivot(mas->node, 0);
@@ -1303,18 +1303,18 @@ static inline unsigned long mas_first_entry(struct ma_state *mas,
 
        slots = ma_slots(mte_to_node(mas->node), mte_node_type(mas->node));
 
-       while ((pivot < limit) && (offset < mt_slot_count(mas->node))) {
-               pivot = mas_safe_pivot(mas, offset);
+       while ((prev_piv < limit) && (offset < mt_slot_count(mas->node))) {
                entry = mas_slot(mas, slots, offset);
                if (entry) {
                        mas_set_offset(mas, offset);
-                       return pivot;
+                       return prev_piv;
                }
+               prev_piv = mas_safe_pivot(mas, offset);
                offset++;
        }
 
        mas->node = MAS_NONE;
-       return pivot;
+       return prev_piv;
 }
 
 /*