From: Matthew Wilcox (Oracle) Date: Wed, 20 Oct 2021 19:21:17 +0000 (-0400) Subject: maple-tree: Handle external locking in mt_set_in_rcu() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c53374f930272a4c8be448021c5049c57b97da38;p=users%2Fwilly%2Flinux.git 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) --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 91765810e5928..f94a8796d758f 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);