Linux XFS filesystem development
 help / color / mirror / Atom feed
* [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; 7+ 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] 7+ messages in thread

end of thread, other threads:[~2026-10-26 15:36 UTC | newest]

Thread overview: 7+ 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-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-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