* [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories
@ 2026-10-23 12:44 Christian Brauner
2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Christian Brauner @ 2026-10-23 12:44 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs,
Gabriel Krisman Bertazi, Christian Brauner (Amutable)
ext4, f2fs and tmpfs keep negative dentries out of casefolded
directories. A negative dentry remembers one spelling of the name and
the next create() through it would write that spelling to disk.
So their ->lookup() doesn't cache a miss and their ->unlink() and
->rmdir() call d_invalidate() on the dentry so that d_delete() doesn't
turn it into a negative dentry.
But d_invalidate() is the wrong primitive for that. It's for a name that
went stale. It walks the subtree, prunes it and detaches every mount it
finds, under namespace_sem, and here that runs from inside the
filesystem's own directory operation. ext4_rmdir() does it with the
journal handle still open and ext4_unlink() does it even when the
unlink failed. All anyone wanted is the unhash.
So d_delete() now unhashes the dentry when the parent is casefolded,
next to the dentry-negative sysctl that does the same for every
directory. ext4, f2fs and tmpfs drop their d_invalidate() calls.
xfs's ascii-ci doesn't set S_CASEFOLD and can't so it d_drop()s instead.
I did consider setting S_CASEFOLD on ascii-ci directories and didn't.
overlayfs warns when a layer's casefold flag disagrees with the
superblock having an encoding, and xfs has none.
Nothing changes for userspace. A miss still isn't cached and a removed
name still leaves no negative dentry behind. Verified with the same
create, unlink, create, readdir and stat sequence in a plain and in a
casefolded directory on tmpfs and on ext4, before and after.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Christian Brauner (2):
dcache: don't leave negative dentries in casefolded directories
xfs: unhash a removed name in ascii-ci mode instead of invalidating it
fs/dcache.c | 8 +++++++-
fs/ext4/namei.c | 18 ------------------
fs/f2fs/namei.c | 9 ---------
fs/xfs/xfs_iops.c | 4 ++--
mm/shmem.c | 7 -------
5 files changed, 9 insertions(+), 37 deletions(-)
---
base-commit: 7be4bc52fd9e0e55dc9a2e0232b89427d2c4b614
change-id: 20261023-work-dcache-casefold-f26205ee1bb7
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/2] dcache: don't leave negative dentries in casefolded directories 2026-10-23 12:44 [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Christian Brauner @ 2026-10-23 12:44 ` Christian Brauner 2026-10-23 13:00 ` sashiko-bot ` (2 more replies) 2026-10-23 12:44 ` [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it Christian Brauner 2026-10-26 15:36 ` [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Gabriel Krisman Bertazi 2 siblings, 3 replies; 9+ messages in thread From: Christian Brauner @ 2026-10-23 12:44 UTC (permalink / raw) To: linux-fsdevel Cc: Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Gabriel Krisman Bertazi, Christian Brauner (Amutable) ext4, f2fs and tmpfs keep negative dentries out of casefolded directories. A negative dentry remembers one spelling of the name and the next create() through it would write that spelling to disk. So their ->lookup() doesn't cache a miss and their ->unlink() and ->rmdir() call d_invalidate() on the dentry so that d_delete() doesn't turn it into a negative dentry. But d_invalidate() is the wrong primitive for that. It's for a name that went stale. It walks the subtree, prunes it and detaches every mount it finds, under namespace_sem, and here that runs from inside the filesystem's own directory operation. ext4_rmdir() does it with the journal handle still open and ext4_unlink() does it even when the unlink failed. All anyone wanted is the unhash. So d_delete() now unhashes the dentry when the parent is casefolded, next to the dentry-negative sysctl that does the same for every directory. ext4, f2fs and tmpfs drop their d_invalidate() calls. Nothing changes for a casefolded directory. A miss still isn't cached and a removed name still doesn't leave a negative dentry behind. The target of a rename over an existing name, which tmpfs also passes through shmem_unlink(), doesn't turn negative either. vfs_rename() detaches its mounts and d_move() unhashes it. A failed unlink or rmdir now leaves the dentry hashed and its mounts in place, as in any other directory. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> --- fs/dcache.c | 8 +++++++- fs/ext4/namei.c | 18 ------------------ fs/f2fs/namei.c | 9 --------- mm/shmem.c | 7 ------- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index efd9332c8407..f5cbb2e24e53 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2746,6 +2746,12 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) return d_lookup(dir, name); } +static __always_inline bool d_delete_drop(struct dentry *dentry) +{ + return dentry_negative_policy || + IS_CASEFOLDED(d_inode(dentry->d_parent)); +} + /* * When a file is deleted, we have two options: * - turn this dentry into a negative dentry @@ -2777,7 +2783,7 @@ void d_delete(struct dentry * dentry) * Are we the only user? */ if (dentry->d_lockref.count == 1) { - if (dentry_negative_policy) + if (d_delete_drop(dentry)) __d_drop(dentry); dentry->d_flags &= ~DCACHE_CANT_MOUNT; dentry_unlink_inode(dentry); diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 6e0630a49e48..c4b1121471e6 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3209,15 +3209,6 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ext4_fc_track_unlink(handle, dentry); retval = ext4_mark_inode_dirty(handle, dir); - /* VFS negative dentries are incompatible with Encoding and - * Case-insensitiveness. Eventually we'll want avoid - * invalidating the dentries here, alongside with returning the - * negative dentries at ext4_lookup(), when it is better - * supported by the VFS for the CI case. - */ - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) - d_invalidate(dentry); - end_rmdir: brelse(bh); if (handle) @@ -3320,15 +3311,6 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); - /* VFS negative dentries are incompatible with Encoding and - * Case-insensitiveness. Eventually we'll want avoid - * invalidating the dentries here, alongside with returning the - * negative dentries at ext4_lookup(), when it is better - * supported by the VFS for the CI case. - */ - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) - d_invalidate(dentry); - out_trace: trace_ext4_unlink_exit(dentry, retval); return retval; diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 233c07fec171..30f6b8448eee 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -631,15 +631,6 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) if (err) goto out; - /* VFS negative dentries are incompatible with Encoding and - * Case-insensitiveness. Eventually we'll want avoid - * invalidating the dentries here, alongside with returning the - * negative dentries at f2fs_lookup(), when it is better - * supported by the VFS for the CI case. - */ - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) - d_invalidate(dentry); - if (IS_DIRSYNC(dir)) err = f2fs_sync_fs(F2FS_I_SB(dir)->sb, 1); out: diff --git a/mm/shmem.c b/mm/shmem.c index 0d891ade18b5..5a353ac32573 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3953,13 +3953,6 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); simple_unlink(dir, dentry); - /* - * For now, VFS can't deal with case-insensitive negative dentries, so - * we invalidate them - */ - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) - d_invalidate(dentry); - return 0; } -- 2.53.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dcache: don't leave negative dentries in casefolded directories 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner @ 2026-10-23 13:00 ` sashiko-bot 2026-10-24 19:20 ` Eric Biggers 2026-10-26 12:19 ` Jan Kara 2 siblings, 0 replies; 9+ messages in thread From: sashiko-bot @ 2026-10-23 13:00 UTC (permalink / raw) To: Christian Brauner; +Cc: linux-ext4, tytso > ext4, f2fs and tmpfs keep negative dentries out of casefolded > directories. A negative dentry remembers one spelling of the name and > the next create() through it would write that spelling to disk. > > So their ->lookup() doesn't cache a miss and their ->unlink() and > ->rmdir() call d_invalidate() on the dentry so that d_delete() doesn't > turn it into a negative dentry. > > But d_invalidate() is the wrong primitive for that. It's for a name that > went stale. It walks the subtree, prunes it and detaches every mount it > finds, under namespace_sem, and here that runs from inside the > filesystem's own directory operation. ext4_rmdir() does it with the > journal handle still open and ext4_unlink() does it even when the > unlink failed. All anyone wanted is the unhash. > > So d_delete() now unhashes the dentry when the parent is casefolded, > next to the dentry-negative sysctl that does the same for every > directory. ext4, f2fs and tmpfs drop their d_invalidate() calls. > > Nothing changes for a casefolded directory. A miss still isn't cached > and a removed name still doesn't leave a negative dentry behind. The > target of a rename over an existing name, which tmpfs also passes > through shmem_unlink(), doesn't turn negative either. vfs_rename() > detaches its mounts and d_move() unhashes it. A failed unlink or rmdir > now leaves the dentry hashed and its mounts in place, as in any other > directory. > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261023-work-dcache-casefold-v1-0-1b0bd5c73a69@kernel.org?part=1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dcache: don't leave negative dentries in casefolded directories 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner 2026-10-23 13:00 ` sashiko-bot @ 2026-10-24 19:20 ` Eric Biggers 2026-10-26 8:12 ` Christian Brauner 2026-10-26 12:19 ` Jan Kara 2 siblings, 1 reply; 9+ messages in thread From: Eric Biggers @ 2026-10-24 19:20 UTC (permalink / raw) To: Christian Brauner Cc: linux-fsdevel, Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Gabriel Krisman Bertazi On Fri, Oct 23, 2026 at 02:44:22PM +0200, Christian Brauner wrote: > +static __always_inline bool d_delete_drop(struct dentry *dentry) > +{ > + return dentry_negative_policy || > + IS_CASEFOLDED(d_inode(dentry->d_parent)); > +} Should this also check IS_ENABLED(CONFIG_UNICODE), so there will be no overhead when CONFIG_UNICODE=n? - Eric ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dcache: don't leave negative dentries in casefolded directories 2026-10-24 19:20 ` Eric Biggers @ 2026-10-26 8:12 ` Christian Brauner 0 siblings, 0 replies; 9+ messages in thread From: Christian Brauner @ 2026-10-26 8:12 UTC (permalink / raw) To: Eric Biggers Cc: linux-fsdevel, Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Gabriel Krisman Bertazi On Sat, Oct 24, 2026 at 12:20:17PM -0700, Eric Biggers wrote: > On Fri, Oct 23, 2026 at 02:44:22PM +0200, Christian Brauner wrote: > > +static __always_inline bool d_delete_drop(struct dentry *dentry) > > +{ > > + return dentry_negative_policy || > > + IS_CASEFOLDED(d_inode(dentry->d_parent)); > > +} > > Should this also check IS_ENABLED(CONFIG_UNICODE), so there will be no > overhead when CONFIG_UNICODE=n? Sounds good. I'll fold then in when applying. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dcache: don't leave negative dentries in casefolded directories 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner 2026-10-23 13:00 ` sashiko-bot 2026-10-24 19:20 ` Eric Biggers @ 2026-10-26 12:19 ` Jan Kara 2 siblings, 0 replies; 9+ messages in thread From: Jan Kara @ 2026-10-26 12:19 UTC (permalink / raw) To: Christian Brauner Cc: linux-fsdevel, Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Gabriel Krisman Bertazi On Fri 23-10-26 14:44:22, Christian Brauner wrote: > ext4, f2fs and tmpfs keep negative dentries out of casefolded > directories. A negative dentry remembers one spelling of the name and > the next create() through it would write that spelling to disk. > > So their ->lookup() doesn't cache a miss and their ->unlink() and > ->rmdir() call d_invalidate() on the dentry so that d_delete() doesn't > turn it into a negative dentry. > > But d_invalidate() is the wrong primitive for that. It's for a name that > went stale. It walks the subtree, prunes it and detaches every mount it > finds, under namespace_sem, and here that runs from inside the > filesystem's own directory operation. ext4_rmdir() does it with the > journal handle still open and ext4_unlink() does it even when the > unlink failed. All anyone wanted is the unhash. > > So d_delete() now unhashes the dentry when the parent is casefolded, > next to the dentry-negative sysctl that does the same for every > directory. ext4, f2fs and tmpfs drop their d_invalidate() calls. > > Nothing changes for a casefolded directory. A miss still isn't cached > and a removed name still doesn't leave a negative dentry behind. The > target of a rename over an existing name, which tmpfs also passes > through shmem_unlink(), doesn't turn negative either. vfs_rename() > detaches its mounts and d_move() unhashes it. A failed unlink or rmdir > now leaves the dentry hashed and its mounts in place, as in any other > directory. > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Yeah, this matches my understanding as well. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/dcache.c | 8 +++++++- > fs/ext4/namei.c | 18 ------------------ > fs/f2fs/namei.c | 9 --------- > mm/shmem.c | 7 ------- > 4 files changed, 7 insertions(+), 35 deletions(-) > > diff --git a/fs/dcache.c b/fs/dcache.c > index efd9332c8407..f5cbb2e24e53 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -2746,6 +2746,12 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) > return d_lookup(dir, name); > } > > +static __always_inline bool d_delete_drop(struct dentry *dentry) > +{ > + return dentry_negative_policy || > + IS_CASEFOLDED(d_inode(dentry->d_parent)); > +} > + > /* > * When a file is deleted, we have two options: > * - turn this dentry into a negative dentry > @@ -2777,7 +2783,7 @@ void d_delete(struct dentry * dentry) > * Are we the only user? > */ > if (dentry->d_lockref.count == 1) { > - if (dentry_negative_policy) > + if (d_delete_drop(dentry)) > __d_drop(dentry); > dentry->d_flags &= ~DCACHE_CANT_MOUNT; > dentry_unlink_inode(dentry); > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index 6e0630a49e48..c4b1121471e6 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -3209,15 +3209,6 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) > ext4_fc_track_unlink(handle, dentry); > retval = ext4_mark_inode_dirty(handle, dir); > > - /* VFS negative dentries are incompatible with Encoding and > - * Case-insensitiveness. Eventually we'll want avoid > - * invalidating the dentries here, alongside with returning the > - * negative dentries at ext4_lookup(), when it is better > - * supported by the VFS for the CI case. > - */ > - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) > - d_invalidate(dentry); > - > end_rmdir: > brelse(bh); > if (handle) > @@ -3320,15 +3311,6 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) > > retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); > > - /* VFS negative dentries are incompatible with Encoding and > - * Case-insensitiveness. Eventually we'll want avoid > - * invalidating the dentries here, alongside with returning the > - * negative dentries at ext4_lookup(), when it is better > - * supported by the VFS for the CI case. > - */ > - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) > - d_invalidate(dentry); > - > out_trace: > trace_ext4_unlink_exit(dentry, retval); > return retval; > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 233c07fec171..30f6b8448eee 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -631,15 +631,6 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) > if (err) > goto out; > > - /* VFS negative dentries are incompatible with Encoding and > - * Case-insensitiveness. Eventually we'll want avoid > - * invalidating the dentries here, alongside with returning the > - * negative dentries at f2fs_lookup(), when it is better > - * supported by the VFS for the CI case. > - */ > - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) > - d_invalidate(dentry); > - > if (IS_DIRSYNC(dir)) > err = f2fs_sync_fs(F2FS_I_SB(dir)->sb, 1); > out: > diff --git a/mm/shmem.c b/mm/shmem.c > index 0d891ade18b5..5a353ac32573 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -3953,13 +3953,6 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) > inode_inc_iversion(dir); > simple_unlink(dir, dentry); > > - /* > - * For now, VFS can't deal with case-insensitive negative dentries, so > - * we invalidate them > - */ > - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) > - d_invalidate(dentry); > - > return 0; > } > > > -- > 2.53.0 > -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it 2026-10-23 12:44 [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Christian Brauner 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner @ 2026-10-23 12:44 ` Christian Brauner 2026-10-23 12:49 ` sashiko-bot 2026-10-26 15:36 ` [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Gabriel Krisman Bertazi 2 siblings, 1 reply; 9+ messages in thread From: Christian Brauner @ 2026-10-23 12:44 UTC (permalink / raw) To: linux-fsdevel Cc: Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Gabriel Krisman Bertazi, Christian Brauner (Amutable) xfs_vn_unlink() uses d_invalidate() on the dentry of a removed name on a case-insensitive filesystem, so that d_delete() doesn't leave a negative dentry behind. The next create() would otherwise reuse with the wrong spelling. But as the comment already states all it wants is the unhash. But d_invalidate() is the wrong primitive for that. It's for a name that went stale. It walks the subtree, prunes it and detaches every mount it finds, under namespace_sem, and here that runs from inside the filesystem's own directory operation. There is nothing below a file or an empty directory to prune, and vfs_unlink() and vfs_rmdir() detach the mounts a few lines later as for every other filesystem. The previous patch moved ext4, f2fs and tmpfs over to d_delete() unhashing the dentry for them. ascii-ci doesn't set S_CASEFOLD, so the VFS can't tell these directories apart, and the feature is deprecated anyway. So just d_drop() the dentry. d_delete() finds it unhashed and turns it negative without hashing it, exactly as before. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> --- fs/xfs/xfs_iops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index d307ec97fac8..bed8372e4bcb 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -416,10 +416,10 @@ xfs_vn_unlink( /* * With unlink, the VFS makes the dentry "negative": no inode, * but still hashed. This is incompatible with case-insensitive - * mode, so invalidate (unhash) the dentry in CI-mode. + * mode, so unhash the dentry in CI-mode. */ if (xfs_has_asciici(XFS_M(dir->i_sb))) - d_invalidate(dentry); + d_drop(dentry); return 0; } -- 2.53.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it 2026-10-23 12:44 ` [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it Christian Brauner @ 2026-10-23 12:49 ` sashiko-bot 0 siblings, 0 replies; 9+ messages in thread From: sashiko-bot @ 2026-10-23 12:49 UTC (permalink / raw) To: Christian Brauner; +Cc: linux-ext4, tytso > xfs_vn_unlink() uses d_invalidate() on the dentry of a removed name on a > case-insensitive filesystem, so that d_delete() doesn't leave a negative > dentry behind. The next create() would otherwise reuse with the wrong > spelling. But as the comment already states all it wants is the unhash. > > But d_invalidate() is the wrong primitive for that. It's for a name that > went stale. It walks the subtree, prunes it and detaches every mount it > finds, under namespace_sem, and here that runs from inside the > filesystem's own directory operation. There is nothing below a file or > an empty directory to prune, and vfs_unlink() and vfs_rmdir() detach the > mounts a few lines later as for every other filesystem. > > The previous patch moved ext4, f2fs and tmpfs over to d_delete() > unhashing the dentry for them. ascii-ci doesn't set S_CASEFOLD, so the > VFS can't tell these directories apart, and the feature is deprecated > anyway. So just d_drop() the dentry. d_delete() finds it unhashed and > turns it negative without hashing it, exactly as before. > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261023-work-dcache-casefold-v1-0-1b0bd5c73a69@kernel.org?part=2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories 2026-10-23 12:44 [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Christian Brauner 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner 2026-10-23 12:44 ` [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it Christian Brauner @ 2026-10-26 15:36 ` Gabriel Krisman Bertazi 2 siblings, 0 replies; 9+ messages in thread From: Gabriel Krisman Bertazi @ 2026-10-26 15:36 UTC (permalink / raw) To: Christian Brauner, linux-fsdevel Cc: Alexander Viro, Jan Kara, linux-ext4, linux-f2fs-devel, linux-xfs, Christian Brauner (Amutable) Christian Brauner <brauner@kernel.org> writes: > ext4, f2fs and tmpfs keep negative dentries out of casefolded > directories. A negative dentry remembers one spelling of the name and > the next create() through it would write that spelling to disk. > > So their ->lookup() doesn't cache a miss and their ->unlink() and > ->rmdir() call d_invalidate() on the dentry so that d_delete() doesn't > turn it into a negative dentry. > > But d_invalidate() is the wrong primitive for that. It's for a name that > went stale. It walks the subtree, prunes it and detaches every mount it > finds, under namespace_sem, and here that runs from inside the > filesystem's own directory operation. ext4_rmdir() does it with the > journal handle still open and ext4_unlink() does it even when the > unlink failed. All anyone wanted is the unhash. > > So d_delete() now unhashes the dentry when the parent is casefolded, > next to the dentry-negative sysctl that does the same for every > directory. ext4, f2fs and tmpfs drop their d_invalidate() calls. > > xfs's ascii-ci doesn't set S_CASEFOLD and can't so it d_drop()s instead. > I did consider setting S_CASEFOLD on ascii-ci directories and didn't. > overlayfs warns when a layer's casefold flag disagrees with the > superblock having an encoding, and xfs has none. > > Nothing changes for userspace. A miss still isn't cached and a removed > name still leaves no negative dentry behind. Verified with the same > create, unlink, create, readdir and stat sequence in a plain and in a > casefolded directory on tmpfs and on ext4, before and after. I think the change looks fine and it passed fstests. Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> Of course, the better approach would be to enable negative dentries but the last attempt went sideways, though not for any good reason. thanks! -- Gabriel Krisman Bertazi ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-10-26 15:36 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-23 12:44 [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Christian Brauner 2026-10-23 12:44 ` [PATCH 1/2] " Christian Brauner 2026-10-23 13:00 ` sashiko-bot 2026-10-24 19:20 ` Eric Biggers 2026-10-26 8:12 ` Christian Brauner 2026-10-26 12:19 ` Jan Kara 2026-10-23 12:44 ` [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it Christian Brauner 2026-10-23 12:49 ` sashiko-bot 2026-10-26 15:36 ` [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Gabriel Krisman Bertazi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox