From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73BC12135AD; Thu, 26 Feb 2026 13:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772112422; cv=none; b=T9Uhwg39X1oMnjRV8VvrxLVl91haiAg8ijhn8b1sBTd3dZfu/Cd5uax4koZr8I/1kCKB/E4ujG0V1NZhwLbuz0ra9+/LkmewEq71Pl3sM8v6tging2s9XW72EIdlbWPvG7ymK2P6dmRXBUn72k8yL/u+favTx1Yfh+HBsvEzJ58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772112422; c=relaxed/simple; bh=f0Ps20ke6Tu90NeJbb7BlgaGF8G/k6iumdbr2OfaiE4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TNnwxXz6wIMUtAX8pWB5AGHrWfYDHifg9TqzdNKsvkHdFtEubEfYathW1+GWBf33iqrO02vdI4vrR2ig3Ud1sFsdZuufkN0CAATU80zgjm/qqVl6wS0KvIDyLBOFx5J7wuIepRXYzzE4mIsgmUjO2g1xGdWE0noPuQ888awQC8g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h+ftwt1h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h+ftwt1h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 262A6C116C6; Thu, 26 Feb 2026 13:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772112422; bh=f0Ps20ke6Tu90NeJbb7BlgaGF8G/k6iumdbr2OfaiE4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=h+ftwt1hFWuk0zBQ+q5kizu3/Zw+G/ztSnBuF4hGTnLedZ+PsXAJkVqQxp3oiKTmC VbPuyqXIM6bziJGo26/ar9QPa3Mn9n7SU4gDHWH5F/76KM6qwWoy2IXEcO8gbLGgHT ZIn+kP1Dx08x3xalaDxmCShdXjZOO+iMhBhphXRkl9VJurk3Yvi6tyqXSKYPyUtMM0 bcFX5semSa9iYA6IFukrlNBcw97UNUp1KGnfCgsKG0Q9zJP2z6HVnRIMy/ZKCmZ2F6 WNd18/gy9eag+XTve+r+FEq3gCrEps6LK+j09UOM4xSg0HKqC4MEvgkneaPttl1KWF YafZ576b3ZCOQ== Message-ID: <1165a90b-acbf-4c0d-a7e3-3972eba0d35a@kernel.org> Date: Thu, 26 Feb 2026 08:27:00 -0500 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/3] fs: add umount notifier chain for filesystem unmount notification To: Amir Goldstein Cc: Jan Kara , NeilBrown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Chuck Lever , Christian Brauner References: <20260224163908.44060-1-cel@kernel.org> <20260224163908.44060-2-cel@kernel.org> <20260226-alimente-kunst-fb9eae636deb@brauner> From: Chuck Lever Content-Language: en-US Organization: kernel.org In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/26/26 5:52 AM, Amir Goldstein wrote: > On Thu, Feb 26, 2026 at 9:48 AM Christian Brauner wrote: >> >> On Tue, Feb 24, 2026 at 11:39:06AM -0500, Chuck Lever wrote: >>> From: Chuck Lever >>> >>> Kernel subsystems occasionally need notification when a filesystem >>> is unmounted. Until now, the only mechanism available is the fs_pin >>> infrastructure, which has limited adoption (only BSD process >>> accounting uses it) and VFS maintainers consider it deprecated. >>> >>> Add an SRCU notifier chain that fires during mount teardown, >>> following the pattern established by lease_notifier_chain in >>> fs/locks.c. The notifier fires after processing stuck children but >>> before fsnotify_vfsmount_delete(), at which point SB_ACTIVE is >>> still set and the superblock remains fully accessible. > > Did you see commit 74bd284537b34 ("fsnotify: Shutdown fsnotify > before destroying sb's dcache")? > > Does it make the fsnotify_sb_delete() hook an appropriate place > for this cleanup? > > We could send an FS_UNMOUNT event on sb, the same way as we send > it on inode in fsnotify_unmount_inodes(). > >> >> What I don't understand is why you need this per-mount especially >> because you say above "when a filesystem is mounted. Could you explain >> this in some more details, please? >> > > The confusing thing is that FS_UNMOUNT/IN_UNMOUNT are sent > for inotify when the sb is destroyed, not when the mount is unmounted. > > If we wanted we could also send FS_UNMOUNT in fsnotify_vfsmount_delete(), > but that would be too confusing. > > I think the only reason that we did not add fanotify support for FAN_UNMOUNT > is this name confusion, but there could be other reasons which I don't > remember. > >> Also this should take namespaces into account somehow, right? As Al >> correctly observed anything that does CLONE_NEWNS and inherits your >> mountable will generate notifications. Like, if systemd spawns services, >> if a container runtime start, if someone uses unshare you'll get >> absolutely flooded with events. I'm pretty sure that is not what you >> want and that is defo not what the VFS should do... I agree with Al's earlier comment and have added some protection there for the next revision of the series. >> 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. -- Chuck Lever