Linux filesystem development
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
	"Paul E. McKenney" <paulmck@kernel.org>,
	NeilBrown <neil@brown.name>, Alexander Larsson <alexl@redhat.com>,
	Jan Kara <jack@suse.cz>, Jeff Layton <jlayton@kernel.org>,
	lkmm@lists.linux.dev
Subject: Re: [PATCH 4/9] fs: unmount without a grace period when nothing else holds the mounts
Date: Sun, 18 Oct 2026 05:16:30 +0100	[thread overview]
Message-ID: <20261018041630.GE3535232@ZenIV> (raw)
In-Reply-To: <20261012-work-mount-gp_on_demand-proposal-v1-4-43f60221a7d0@kernel.org>

On Mon, Oct 12, 2026 at 05:39:17PM +0200, Christian Brauner wrote:

>  fs/namespace.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 79 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 8c6673bd8c03..435e5f6db880 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1489,10 +1489,12 @@ static void mntput_no_expire(struct mount *mnt)
>  		 * Since we don't do lock_mount_hash() here,
>  		 * ->mnt_ns can change under us.  However, if it's
>  		 * non-NULL, then there's a reference that won't
> -		 * be dropped until after an RCU delay done after
> -		 * turning ->mnt_ns NULL.  So if we observe it
> -		 * non-NULL under rcu_read_lock(), the reference
> -		 * we are dropping is not the final one.
> +		 * be dropped until after turning ->mnt_ns NULL and
> +		 * either an RCU delay or a look under mount_lock
> +		 * that found it to be the only one left, which it
> +		 * isn't while ours is counted (mntput_unheld()).

Umm....   something like "either an RCU delay or having mntput_unheld()
observe the refcount to be 1 in a mount_lock exclusive scope.  The latter
can't happen until the mnt_dec_count() below", perhaps?  Probably still
too convoluted...

I'm not trying to nitpick - the place _is_ subtle and we are pretty
much guaranteed to look at it quite a few times down the road...

So basically you are relying upon the following:
1) RCU references to mounts are only used inside RCU read-side
critical scopes that have
	* mount_lock sampled prior to having observed the mount
in a live state
	* __legitimize_mnt() with the sampled value of mount_lock
done to obtain a counting reference
2) there's an RCU delay between having been observed live and freeing.
3) ->mnt_parent of a something that had been live in an RCU scope will
point to something that had been live in the same RCU scope.
4) ->root.mnt and ->pwd.mnt observed under ->seq are live.
5) anything observed in mount hash under mount_lock is live.

Might work...  FWIW, I wonder (again) if we should replace the check for
mnt->mnt.mnt_flags & MNT_DOOMED in the slow path of mntput_no_expire()
with WARN_ON() - it really should never happen.

  reply	other threads:[~2026-10-18  4:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 15:39 [PATCH 0/9] fs: unmount without a grace period when nothing else holds the mounts Christian Brauner
2026-10-12 15:39 ` [PATCH 1/9] ovl: free the ovl_fs after a grace period Christian Brauner
2026-10-12 15:39 ` [PATCH 2/9] fs: split the final put out of mntput_no_expire_slowpath() Christian Brauner
2026-10-12 15:39 ` [PATCH 3/9] fs: drop the caller's umount(2) reference under mount_lock Christian Brauner
2026-10-18  2:20   ` Al Viro
2026-10-12 15:39 ` [PATCH 4/9] fs: unmount without a grace period when nothing else holds the mounts Christian Brauner
2026-10-18  4:16   ` Al Viro [this message]
2026-10-12 15:39 ` [PATCH 5/9] fs: port kern_unmount{_array}() to mntput_unmounted() Christian Brauner
2026-10-12 15:39 ` [PATCH 6/9] selftests/filesystems: check that unheld mounts are gone after umount Christian Brauner
2026-10-12 15:39 ` [PATCH 7/9] Documentation/litmus-tests: add the mount reference count tests Christian Brauner
2026-10-12 15:39 ` [PATCH 8/9] ipc: free the namespace after a grace period Christian Brauner
2026-10-12 15:39 ` [PATCH 9/9] ipc: unmount the mqueue mount with kern_unmount() Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261018041630.GE3535232@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=alexl@redhat.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lkmm@lists.linux.dev \
    --cc=neil@brown.name \
    --cc=paulmck@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox