]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Merge remote-tracking branch 'willy/maple2' into maple2
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 15 Oct 2019 00:44:08 +0000 (20:44 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 15 Oct 2019 00:47:15 +0000 (20:47 -0400)
1  2 
include/linux/maple_tree.h
lib/maple_tree.c
lib/test_maple_tree.c

index eb1626010935aa7cf071a0a11432dd18433cd4b9,3219fec8965b13075264f5ce83101342febb96b6..826165e4cf695d8cb78da036116c39f26e2f5fce
@@@ -304,32 -304,36 +304,63 @@@ bool mas_nomem(struct ma_state *mas, gf
  void mas_pause(struct ma_state *mas);
  void maple_tree_init(void);
  
 +/**
 + * mas_for_each() - Iterate over a range of the maple tree.
 + * @mas: Maple Tree operation state (maple_state)
 + * @entry: Entry retrieved from the tree
 + * @max: maximum index to retrieve from the tree
 + *
 + * When returned, mas->index and mas->last will hold the entire range for the
 + * entry.
 + *
 + * Note: may return the zero entry.
 + *
 + */
 +#define mas_for_each(mas, entry, max) \
 +      while ((entry = mas_find(mas, max)) != NULL)
 +
 +/**
 + * mt_for_each - Searches for an entry starting at index until max.
 + *
 + *
 + *
 + * Note: Will not return the zero entry.
 + *
 + *
 + */
 +#define mt_for_each(tree, entry, index, max) \
 +      for (entry = mt_find(mt, index, max); \
 +           entry; entry = mt_find_after(mt, &index, max))
+ /**
+  * mas_set_range() - Set up Maple Tree operation state for a different index.
+  * @xas: Maple Tree operation state.
+  * @start: New start of range in the Maple Tree.
+  * @last: New end of range in the Maple Tree.
+  *
+  * Move the operation state to refer to a different range.  This will
+  * have the effect of starting a walk from the top; see mas_next()
+  * to move to an adjacent index.
+  */
+ static inline void mas_set_range(struct ma_state *mas, unsigned long start,
+               unsigned long last)
+ {
+       mas->index = start;
+       mas->last = last;
+       mas->node = MAS_START;
+ }
+ /**
+  * mas_set() - Set up Maple Tree operation state for a different index.
+  * @xas: Maple Tree operation state.
+  * @index: New index into the Maple Tree.
+  *
+  * Move the operation state to refer to a different index.  This will
+  * have the effect of starting a walk from the top; see mas_next()
+  * to move to an adjacent index.
+  */
+ static inline void mas_set(struct ma_state *mas, unsigned long index)
+ {
+       mas_set_range(mas, index, index);
+ }
  
  #endif
index 3f696a1eaec1b2addc675e49d1ef6a02f83d1090,c916a27c0ab9758037f05449fc8ab09c9aaa4685..6f14ed658a0e5739ca4592f7da21b01153dfad82
@@@ -3195,15 -3223,16 +3195,16 @@@ next
                }
        }
  
 -      ma_set_slot(mas, i);
 +      mas_set_slot(mas, i);
        return found;
  ascend:
 -      if (ma_is_root(mas->node))
 +      if (mte_is_root(mas->node))
                found = true;
  
 -      ma_set_slot(mas, i);
 +      mas_set_slot(mas, i);
        return found;
  }
  /*
   * Private: Returns true if mas->node is a leaf
   */
@@@ -3270,9 -3299,10 +3271,10 @@@ skip_entry
                mas->node = next;
        }
  done:
 -      ma_set_slot(mas, i);
 +      mas_set_slot(mas, i);
        return ret;
  }
  static inline bool _mas_walk(struct ma_state *mas)
  {
        mas->node = mas_start(mas);
@@@ -3298,9 -3328,12 +3300,12 @@@ static inline int mas_safe_slot(struct 
        }
        return false;
  }
  static inline int mas_dead_node(struct ma_state *mas, unsigned long index)
  {
 -      if (!mt_dead_node(mas->node))
+       if (!mas->node)
+               return 0;
 +      if (!mte_dead_node(mas->node))
                return 0;
  
        mas->index = index;
@@@ -4026,9 -4060,9 +4036,9 @@@ int mtree_store_range(struct maple_tre
        if (first > last)
                return -EINVAL;
  
-       mtree_lock(mas.tree);
+       mas_lock(&mas);
  retry:
 -      ma_add(&mas, entry, true, true);
 +      mas_add(&mas, entry, true, true);
        if (mas_nomem(&mas, gfp))
                goto retry;
  
Simple merge