maple_tree: Add mas_root_locked() and mas_root(), rename protected() to locked()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 28 Sep 2020 19:25:20 +0000 (15:25 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:24 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index f401b48f39021b2645a1b30797e782a076e78ef3..6ab6a50dabfbfffa72f15d2697d6ff5efb1bf327 100644 (file)
@@ -614,7 +614,7 @@ static inline void __rcu **ma_slots(struct maple_node *mn, enum maple_type mt)
        }
 }
 
-static inline void *mas_slot_protected(struct ma_state *mas, void **slots,
+static inline void *mas_slot_locked(struct ma_state *mas, void **slots,
                                       unsigned char offset)
 {
        if (mt_in_rcu(mas->tree))
@@ -639,6 +639,22 @@ static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
                       offset);
 }
 
+static inline void *mas_root(struct ma_state *mas)
+{
+       if (mt_in_rcu(mas->tree))
+               return rcu_dereference(mas->tree->ma_root)
+
+       return mas->tree->ma_root;
+}
+
+static inline void *mas_root_locked(struct ma_state *mas)
+{
+       if (mt_in_rcu(mas->tree))
+               return rcu_dereference_protected(mas->tree->ma_root,
+                                       lockdep_is_held(&mas->tree->ma_lock));
+
+       return mas->tree->ma_root;
+}
 /*
  * ma_set_slot() - Set a nodes rcu slot.
  *
@@ -1084,7 +1100,7 @@ static inline unsigned long mas_leaf_max_gap(struct ma_state *mas)
 
        if (ma_is_dense(mt)) {
                for (i = 0; i < mt_slot_count(mas->node); i++) {
-                       if (mas_slot_protected(mas, slots, i)) {
+                       if (mas_slot_locked(mas, slots, i)) {
                                if (gap > max_gap)
                                        max_gap = gap;
                                gap = 0;
@@ -2676,13 +2692,11 @@ static inline int mas_commit_b_node(struct ma_state *mas,
 reused_node:
        mas_update_gap(mas);
        return 2;
-
 }
 
 static inline int mas_root_expand(struct ma_state *mas, void *entry)
 {
-       void *contents = rcu_dereference_protected(mas->tree->ma_root,
-                               lockdep_is_held(&mas->tree->ma_lock));
+       void *contents = mas_root_locked(mas);
        enum maple_type type = maple_leaf_64;
        int slot = 0;
 
@@ -2721,8 +2735,7 @@ static inline int ma_root_ptr(struct ma_state *mas, void *entry,
                return 0;
 
        if (mas->tree->ma_root && mas->last == 0) {
-               contents = rcu_dereference_protected(mas->tree->ma_root,
-                       lockdep_is_held(&mas->tree->ma_lock));
+               contents = mas_root_locked(mas);
                if (!overwrite)
                        goto exists;
        } else {