]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix circular dependencies that will be created when mmap is
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 31 Oct 2019 14:45:51 +0000 (10:45 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 18:56:38 +0000 (14:56 -0400)
modified.

This also required moving mas_retry from .h to .c to avoid xarray
include loop.

Also fix mas_restart to reset mas ranges.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c

index 06041c4041fea5858905fe3d28d273ef7693db14..3230aaa6a7cd2351237e4b4596957bb857da8496 100644 (file)
@@ -11,8 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/rcupdate.h>
 #include <linux/spinlock.h>
-#include <linux/types.h>
-#include <linux/xarray.h>
 
 /*
  * Allocated nodes are mutable until they have been inserted into the tree,
@@ -25,7 +23,7 @@
  *
  * Nodes in the tree point to their parent unless bit 0 is set.
  */
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) || defined(BUILD_VDSO32_64)
 #define MAPLE_NODE_SLOTS       15      /* 128 bytes including ->parent */
 #define MAPLE_RANGE64_SLOTS    8       /* 128 bytes */
 #define MAPLE_ARANGE64_SLOTS   5       /* 120 bytes */
@@ -317,32 +315,8 @@ void maple_tree_init(void);
 static inline void mas_reset(struct ma_state *mas)
 {
        mas->node = MAS_START;
-}
-
-/**
- * mas_retry() - Retry the operation if appropriate.
- * @mas: Maple Tree operation state.
- * @entry: Entry from tree.
- *
- * The advanced functions may sometimes return an internal entry, such as
- * a retry entry or a zero entry.  This function sets up the @mas to restart
- * the walk from the head of the array if needed.
- *
- * Context: Any context.
- * Return: true if the operation needs to be retried.
- */
-static inline bool mas_retry(struct ma_state *mas, const void *entry)
-{
-       if (xa_is_skip(entry))
-               return true;
-       if (xa_is_deleted(entry))
-               return true;
-       if (xa_is_zero(entry))
-               return true;
-       if (!xa_is_retry(entry))
-               return false;
-       mas_reset(mas);
-       return true;
+       mas->max = ULONG_MAX;
+       mas->min = 0;
 }
 
 /**
@@ -373,6 +347,8 @@ static inline bool mas_retry(struct ma_state *mas, const void *entry)
        for (entry = mt_find(mt, index, max); \
             entry; entry = mt_find_after(mt, &index, max))
 
+bool mas_retry(struct ma_state *mas, const void *entry);
+
 /**
  * mas_set_range() - Set up Maple Tree operation state for a different index.
  * @mas: Maple Tree operation state.
@@ -405,4 +381,4 @@ static inline void mas_set(struct ma_state *mas, unsigned long index)
 
        mas_set_range(mas, index, index);
 }
-#endif
+#endif /*_LINUX_MAPLE_TREE_H */
index bc8f63c422c781b35d67b19a86abc8109aaab24e..6b01226b90f015668e74805c1c90269fea50944e 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include <linux/maple_tree.h>
+#include <linux/xarray.h>
+#include <linux/types.h>
 #include <linux/export.h>
 #include <linux/slab.h>
 #include <asm/barrier.h>
@@ -738,6 +740,32 @@ static inline void mas_update_limits(struct ma_state *mas, unsigned char slot,
                mas->max = _mte_get_pivot(mas->node, slot, type);
 }
 
+/**
+ * mas_retry() - Retry the operation if appropriate.
+ * @mas: Maple Tree operation state.
+ * @entry: Entry from tree.
+ *
+ * The advanced functions may sometimes return an internal entry, such as
+ * a retry entry or a zero entry.  This function sets up the @mas to restart
+ * the walk from the head of the array if needed.
+ *
+ * Context: Any context.
+ * Return: true if the operation needs to be retried.
+ */
+bool mas_retry(struct ma_state *mas, const void *entry)
+{
+       if (xa_is_skip(entry))
+               return true;
+       if (xa_is_deleted(entry))
+               return true;
+       if (xa_is_zero(entry))
+               return true;
+       if (!xa_is_retry(entry))
+               return false;
+       mas_reset(mas);
+       return true;
+}
+
 static inline void mas_encoded_parent(struct ma_state *mas)
 {
        struct maple_enode *p_enode, *gp_enode;