}
static inline struct maple_enode *ma_get_slot(
- const struct maple_node *mn, unsigned char slot,
+ struct maple_node *mn, unsigned char offset,
enum maple_type type, struct maple_tree *mtree)
{
- switch (type) {
- default:
- case maple_arange_64:
- return rcu_dereference_check(mn->ma64.slot[slot],
- lockdep_is_held(&mtree->ma_lock));
- case maple_range_64:
- case maple_leaf_64:
- return rcu_dereference_check(mn->mr64.slot[slot],
- lockdep_is_held(&mtree->ma_lock));
- case maple_dense:
- return rcu_dereference_check(mn->slot[slot],
+ void **slots = ma_get_slots(mn, type);
+
+ return rcu_dereference_check(slots[offset],
lockdep_is_held(&mtree->ma_lock));
- }
}
static inline struct maple_enode *_mte_get_slot(
- const struct maple_enode *mn, unsigned char slot,
+ struct maple_enode *mn, unsigned char slot,
enum maple_type type, struct maple_tree *mtree)
{
return ma_get_slot(mte_to_node(mn), slot, type, mtree);
}
-static inline struct maple_enode *mte_get_slot(const struct maple_enode *mn,
+static inline struct maple_enode *mte_get_slot(struct maple_enode *mn,
unsigned char slot, struct maple_tree *mtree)
{
return _mte_get_slot(mn, slot, mte_node_type(mn), mtree);
}
-static inline struct maple_enode *mas_get_slot(const struct ma_state *mas,
+static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
unsigned char slot)
{
return mte_get_slot(mas->node, slot, mas->tree);
unsigned long gap = 0;
void *entry = NULL;
int i;
+ void **slots = ma_get_slots(mte_to_node(mas->node), mt);
if (ma_is_dense(mt)) {
for (i = 0; i < mt_slot_count(mas->node); i++) {
- entry = mas_get_slot(mas, i);
+ entry = slots[i];
if (entry) {
if (gap > max_gap)
max_gap = gap;
pend = mas->max;
gap = pend - pstart + 1;
- entry = mas_get_slot(mas, i);
-
+ entry = slots[i];
if (entry)
goto next;
static inline unsigned long mas_first_node(struct ma_state *mas,
unsigned long limit)
{
- int slot = mas_offset(mas) - 1;
- unsigned char count = mt_slot_count(mas->node);
+ int offset = mas_offset(mas) - 1;
+ enum maple_type mt = mte_node_type(mas->node);
unsigned long pivot, min = mas->min;
+ void **slots = ma_get_slots(mte_to_node(mas->node), mt);
- while (++slot < count) {
+ while (++offset < mt_slots[mt]) {
struct maple_enode *mn;
- pivot = mas_safe_pivot(mas, slot);
+ pivot = _mas_safe_pivot(mas, offset, mt);
if (pivot > limit)
goto no_entry;
- mn = mas_get_slot(mas, slot);
-
+ mn = rcu_dereference_check(slots[offset],
+ lockdep_is_held(mas->tree->ma_lock));
if (!mn) {
min = pivot + 1;
continue;
mas->min = min;
mas->node = mn;
}
- mas_set_offset(mas, slot);
+ mas_set_offset(mas, offset);
return pivot;
}
*/
static inline bool mas_new_child(struct ma_state *mas, struct ma_state *child)
{
- unsigned char slot, end = mt_slot_count(mas->node);
+ enum maple_type mt = mte_node_type(mas->node);
+ unsigned char offset;
struct maple_enode *entry;
+ void **slots = ma_get_slots(mte_to_node(mas->node), mt);
- for (slot = mas_offset(mas); slot < end; slot++) {
- entry = mas_get_slot(mas, slot);
+ for (offset= mas_offset(mas); offset < mt_slots[mt]; offset++) {
+ entry = slots[offset];
if (!entry) // end of node data.
break;
if (mte_parent(entry) == mas_mn(mas)) {
- mas_set_offset(mas, slot);
+ mas_set_offset(mas, offset);
mas_dup_state(child, mas);
- mas_set_offset(mas, slot + 1);
+ mas_set_offset(mas, offset + 1);
mas_descend(child);
return true;
}
unsigned char mab_start)
{
int i, j;
+ void **slots = ma_get_slots(mte_to_node(mas->node),
+ mte_node_type(mas->node));
for (i = mas_start, j = mab_start; i <= mas_end; i++, j++) {
- b_node->slot[j] = mas_get_slot(mas, i);
+ b_node->slot[j] = slots[i];
if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree))
b_node->gap[j] = mte_get_gap(mas->node, i);