>From 660bddec1241c46a7722f5c9b66a2450b5f85751 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 18 Apr 2025 13:33:43 +0200 Subject: [PATCH] [UNTESTED]: mount: sample and kick of grace period during umount Sample the current rcu state and kick off a new grace period after we're done with umount_tree() and make namespace_unlock() take the previous state into account before invoking synchronize_rcu_expedited(). Signed-off-by: Christian Brauner --- fs/namespace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index d9ca80dcc544..287189e85af5 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -77,6 +77,7 @@ static struct hlist_head *mount_hashtable __ro_after_init; static struct hlist_head *mountpoint_hashtable __ro_after_init; static struct kmem_cache *mnt_cache __ro_after_init; static DECLARE_RWSEM(namespace_sem); +static struct rcu_gp_oldstate rcu_unmount_gp; static HLIST_HEAD(unmounted); /* protected by namespace_sem */ static LIST_HEAD(ex_mountpoints); /* protected by namespace_sem */ static DEFINE_SEQLOCK(mnt_ns_tree_lock); @@ -1817,7 +1818,7 @@ static void namespace_unlock(void) if (likely(hlist_empty(&head))) return; - synchronize_rcu_expedited(); + cond_synchronize_rcu_expedited_full(&rcu_unmount_gp); hlist_for_each_entry_safe(m, p, &head, mnt_umount) { hlist_del(&m->mnt_umount); @@ -1939,6 +1940,9 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) */ mnt_notify_add(p); } + + /* Record current grace period state and kick of new grace period. */ + start_poll_synchronize_rcu_expedited_full(&rcu_unmount_gp); } static void shrink_submounts(struct mount *mnt); -- 2.47.2