]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracefs: Add d_delete to remove negative dentries
authorSteven Rostedt <rostedt@goodmis.org>
Wed, 11 Jun 2025 16:18:15 +0000 (12:18 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:15 +0000 (16:28 +0200)
commit839312bff2c95a879a63fba150ad820b13a5dfdd
tree8223275c0e63ff8dbb52a6b03c882e6c4505a485
parentd7e28036b0e938c689d98efa812d4138cda38e07
tracefs: Add d_delete to remove negative dentries

[ Upstream commit d9b13cdad80dc11d74408cf201939a946e9303a6 ]

If a lookup in tracefs is done on a file that does not exist, it leaves a
dentry hanging around until memory pressure removes it. But eventfs
dentries should hang around as when their ref count goes to zero, it
requires more work to recreate it. For the rest of the tracefs dentries,
they hang around as their dentry is used as a descriptor for the tracing
system. But if a file lookup happens for a file in tracefs that does not
exist, it should be deleted.

Add a .d_delete callback that checks if dentry->fsdata is set or not. Only
eventfs dentries set fsdata so if it has content it should not be deleted
and should hang around in the cache.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/tracefs/inode.c