[v3,05/48] maple_tree: Fix handle of invalidated state in mas_wr_store_setup()

Message ID 20230117023335.1690727-6-Liam.Howlett@oracle.com
State New
Headers
Series VMA tree type safety and remove __vma_adjust() |

Commit Message

Liam R. Howlett Jan. 17, 2023, 2:34 a.m. UTC
  From: "Liam R. Howlett" <Liam.Howlett@oracle.com>

If an invalidated maple state is encountered during write, reset the
maple state to MAS_START.  This will result in a re-walk of the tree to
the correct location for the write.

Link: https://lore.kernel.org/all/20230107020126.1627-1-sj@kernel.org/
Reported-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 lib/maple_tree.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 9af88726d88a..03429149870c 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5619,6 +5619,9 @@  static inline void mte_destroy_walk(struct maple_enode *enode,
 
 static void mas_wr_store_setup(struct ma_wr_state *wr_mas)
 {
+	if (unlikely(mas_is_paused(wr_mas->mas)))
+		mas_reset(wr_mas->mas);
+
 	if (!mas_is_start(wr_mas->mas)) {
 		if (mas_is_none(wr_mas->mas)) {
 			mas_reset(wr_mas->mas);