From c53374f930272a4c8be448021c5049c57b97da38 Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Wed, 20 Oct 2021 15:21:17 -0400 Subject: [PATCH] maple-tree: Handle external locking in mt_set_in_rcu() If the tree is marked as externally locked, we must not take the ma_lock. Instead, assert that the external lock is held. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/maple_tree.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 91765810e592..f94a8796d758 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -468,9 +468,14 @@ static inline void mt_clear_in_rcu(struct maple_tree *mt) if (!mt_in_rcu(mt)) return; - mtree_lock(mt); - mt->ma_flags &= ~MT_FLAGS_USE_RCU; - mtree_unlock(mt); + if (mt_external_lock(mt)) { + BUG_ON(!lock_is_held(mt->ma_external_lock)); + mt->ma_flags &= ~MT_FLAGS_USE_RCU; + } else { + mtree_lock(mt); + mt->ma_flags &= ~MT_FLAGS_USE_RCU; + mtree_unlock(mt); + } } /** @@ -481,9 +486,14 @@ static inline void mt_set_in_rcu(struct maple_tree *mt) if (mt_in_rcu(mt)) return; - mtree_lock(mt); - mt->ma_flags |= MT_FLAGS_USE_RCU; - mtree_unlock(mt); + if (mt_external_lock(mt)) { + BUG_ON(!lock_is_held(mt->ma_external_lock)); + mt->ma_flags |= MT_FLAGS_USE_RCU; + } else { + mtree_lock(mt); + mt->ma_flags |= MT_FLAGS_USE_RCU; + mtree_unlock(mt); + } } void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max); -- 2.50.1