Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	 linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	 linux-xfs@vger.kernel.org,
	Gabriel Krisman Bertazi <krisman@kernel.org>,
	 "Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it
Date: Fri, 23 Oct 2026 14:44:23 +0200	[thread overview]
Message-ID: <20261023-work-dcache-casefold-v1-2-1b0bd5c73a69@kernel.org> (raw)
In-Reply-To: <20261023-work-dcache-casefold-v1-0-1b0bd5c73a69@kernel.org>

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


  parent reply	other threads:[~2026-10-23 12:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Christian Brauner [this message]
2026-10-23 12:49   ` [PATCH 2/2] xfs: unhash a removed name in ascii-ci mode instead of invalidating it sashiko-bot
2026-10-26 15:36 ` [PATCH 0/2] dcache: don't leave negative dentries in casefolded directories Gabriel Krisman Bertazi

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=20261023-work-dcache-casefold-v1-2-1b0bd5c73a69@kernel.org \
    --to=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=krisman@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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