All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: Jan Kara <jack@suse.cz>, Amir Goldstein <amir73il@gmail.com>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.com>, NeilBrown <neilb@ownmail.net>,
	Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH v3 1/3] fs: add umount notifier chain for filesystem unmount notification
Date: Fri, 27 Feb 2026 10:10:17 -0500	[thread overview]
Message-ID: <3cff098e-74a8-4111-babb-9c13c7ba2344@kernel.org> (raw)
In-Reply-To: <jxyalrg3a2yjtjfmdylncg7fz63jstbq6pwhhqlaaxju5sk72f@55lb7mfucc5i>

On 2/26/26 8:32 AM, Jan Kara wrote:
> On Thu 26-02-26 08:27:00, Chuck Lever wrote:
>> On 2/26/26 5:52 AM, Amir Goldstein wrote:
>>> On Thu, Feb 26, 2026 at 9:48 AM Christian Brauner <brauner@kernel.org> wrote:
>>>> Another thing: These ad-hoc notifiers are horrific. So I'm pitching
>>>> another idea and I hope that Jan and Amir can tell me that this is
>>>> doable...
>>>>
>>>> Can we extend fsnotify so that it's possible for a filesystem to
>>>> register "internal watches" on relevant objects such as mounts and
>>>> superblocks and get notified and execute blocking stuff if needed.
>>>>
>>>
>>> You mean like nfsd_file_fsnotify_group? ;)
>>>
>>>> Then we don't have to add another set of custom notification mechanisms
>>>> but have it available in a single subsystem and uniformely available.
>>>>
>>>
>>> I don't see a problem with nfsd registering for FS_UNMOUNT
>>> event on sb (once we add it).
>>>
>>> As a matter of fact, I think that nfsd can already add an inode
>>> mark on the export root path for FS_UNMOUNT event.
>>
>> There isn't much required here aside from getting a synchronous notice
>> that the final file system unmount is going on. I'm happy to try
>> whatever mechanism VFS maintainers are most comfortable with.
> 
> Yeah, then as Amir writes placing a mark with FS_UNMOUNT event on the
> export root path and handling the event in
> nfsd_file_fsnotify_handle_event() should do what you need?

Turns out FS_UNMOUNT doesn't do what I need.

1/3 here has a fatal flaw: the SRCU notifier does not fire until all
files on the mount are closed. The problem is that NFSD holds files
open when there is outstanding NFSv4 state. So the SRCU notifier will
never fire, on umount, to release that state.

FS_UNMOUNT notifiers have the same issue.

They fire from fsnotify_sb_delete() inside generic_shutdown_super(),
which runs inside deactivate_locked_super(), which runs when s_active
drops to 0. That requires all mounts to be freed, which requires all
NFSD files to be closed: the same problem.

For any notification approach to actually do what is needed, it needs to
fire during do_umount(), before propagate_mount_busy(). Something like:

do_umount(mnt):
    <- NEW: notify subsystems, allow them to release file refs
    retval = propagate_mount_busy(mnt, 2)   // now passes
    umount_tree(mnt, ...)

This is what Christian's "internal watches... execute blocking stuff"
would need to enable. The existing fsnotify plumbing (groups, marks,
event dispatch) provides the infrastructure, but a new notification hook
in do_umount() is required — neither fsnotify_vfsmount_delete() nor
fsnotify_sb_delete() fires early enough.

But a hook in do_umount() fires for every mount namespace teardown, not
just admin-initiated unmounts. NFSD's callback would need to filter
(e.g., only act when it's the last mount of a superblock that NFSD is
exporting).

This is why I originally went with fs_pin. Not saying the series should
go back to that, but this is the basic requirement: NFSD needs
notification of a umount request while files are still open on that
mount, so that it can revoke the NFSv4 state and close those files.


-- 
Chuck Lever

  reply	other threads:[~2026-02-27 15:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 16:39 [PATCH v3 0/3] Automatic NFSv4 state revocation on filesystem unmount Chuck Lever
2026-02-24 16:39 ` [PATCH v3 1/3] fs: add umount notifier chain for filesystem unmount notification Chuck Lever
2026-02-26  8:48   ` Christian Brauner
2026-02-26 10:52     ` Amir Goldstein
2026-02-26 13:27       ` Chuck Lever
2026-02-26 13:32         ` Jan Kara
2026-02-27 15:10           ` Chuck Lever [this message]
2026-03-01 14:37             ` Amir Goldstein
2026-03-01 17:20               ` Chuck Lever
2026-03-01 18:09                 ` Amir Goldstein
2026-03-01 18:19                   ` Chuck Lever
2026-03-02  4:09                     ` NeilBrown
2026-03-02 13:57                       ` Chuck Lever
2026-03-02 15:26                         ` Jan Kara
2026-03-02 17:10                           ` Jeff Layton
2026-03-02 17:37                             ` Jan Kara
2026-03-02 17:53                               ` Jeff Layton
2026-03-04 13:17                                 ` Christian Brauner
2026-03-04 15:15                                   ` Chuck Lever
2026-03-02 20:46                               ` NeilBrown
2026-03-02 17:01                         ` Chuck Lever
2026-03-02 20:36                           ` NeilBrown
2026-03-03 20:02                             ` Chuck Lever
2026-03-03 21:23                               ` NeilBrown
2026-03-03 22:50                                 ` Chuck Lever
2026-03-04  1:01                                   ` NeilBrown
2026-03-04 13:05                             ` Christian Brauner
2026-02-24 16:39 ` [PATCH v3 2/3] nfsd: revoke NFSv4 state when filesystem is unmounted Chuck Lever
2026-02-24 16:39 ` [PATCH v3 3/3] nfsd: close cached files on filesystem unmount Chuck Lever
2026-02-24 17:14 ` [PATCH v3 0/3] Automatic NFSv4 state revocation " Al Viro

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=3cff098e-74a8-4111-babb-9c13c7ba2344@kernel.org \
    --to=cel@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@ownmail.net \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.