From 86b00959fb0e3512fc42fdb4f85a7b3ecdc7fe10 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 31 Oct 2019 10:45:51 -0400 Subject: [PATCH] maple_tree: Fix circular dependencies that will be created when mmap is 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 --- include/linux/maple_tree.h | 36 ++++++------------------------------ lib/maple_tree.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 06041c4041fe..3230aaa6a7cd 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -11,8 +11,6 @@ #include #include #include -#include -#include /* * 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 */ diff --git a/lib/maple_tree.c b/lib/maple_tree.c index bc8f63c422c7..6b01226b90f0 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include @@ -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; -- 2.50.1