}
static inline int mas_dead_node(struct ma_state *mas, unsigned long index);
-
-static inline void mas_next_slot(struct ma_state *mas, unsigned long max)
- __must_hold(mas->tree->lock)
-{
- unsigned char slot;
-
- while (1) {
- slot = mte_parent_slot(mas->node);
- if (mte_is_root(mas->node))
- goto no_entry;
-
- mas_ascend(mas);
- if (mas->max > max)
- goto no_entry;
-
- if (slot < mt_slot_count(mas->node) - 1) {
- if (!mas_get_safe_pivot(mas, slot + 1))
- continue;
- slot++;
- goto walk_down;
- }
-
- if (mte_is_root(mas->node))
- goto no_entry;
- }
-
-walk_down:
- do {
- void *entry = NULL;
- if (slot)
- mas->min = mas_get_safe_pivot(mas, slot - 1) + 1;
- mas->max = mas_get_safe_pivot(mas, slot);
- entry = mas_get_rcu_slot(mas, slot);
- mas->node = entry;
- if (mt_is_empty(mas->node))
- goto no_entry;
-
- if (mte_is_leaf(mas->node)) {
- goto found_next;
- }
- slot = 0;
-
- } while (1);
-
-found_next:
- mas_set_slot(mas, slot);
- return;
-
-no_entry:
- mas->node = MAS_NONE;
-}
-/** Private
- * mas_prev_slot() - Find the previous leaf slot, regardless of having an
- * entry or not
- *
- * NOTE: Not read safe - does not check for dead nodes.
- * Not root safe, cannot be the root node.
- */
-static inline void mas_prev_slot(struct ma_state *mas, unsigned long min)
- __must_hold(ms->tree->lock)
-{
- unsigned char slot;
-
- if (mte_is_root(mas->node))
- goto no_entry;
-
- while (1) {
- slot = mte_parent_slot(mas->node);
- mas_ascend(mas);
- if (mas->min < min)
- goto no_entry;
-
- if (slot) {
- slot--;
- goto walk_down;
- }
- if (mte_is_root(mas->node))
- goto no_entry;
- }
-
-walk_down:
- do {
- if (slot)
- mas->min = mas_get_safe_pivot(mas, slot - 1);
- mas->max = mas_get_safe_pivot(mas, slot);
- mas->node = mas_get_rcu_slot(mas, slot);
- if (mte_is_leaf(mas->node))
- goto done;
-
- slot = _mas_data_end(mas, mte_node_type(mas->node), &mas->max);
- } while (1);
-
-done:
- mas_set_slot(mas, slot);
- return;
-
-no_entry:
- mas->node = MAS_NONE;
-}
-
/** Private
* mas_prev_node() - Find the prev non-null entry at the same level in the
* tree. The prev value will be mas->node[mas_get_slot(mas)] or MAS_NONE.