linux/super: add tunable to request immediate reclaim of unused dentries

Traditionally, unused dentries would be cached in the dentry cache until
the associated entry is no longer on disk. The cached dentry continues
to hold an inode reference, causing the inode to be pinned (see previous
commit).

Here we implement the dentry op d_delete, which is roughly analogous to
the drop_inode superblock op, and add a zfs_delete_dentry tunable to
control its behaviour. By default it continues the traditional
behaviour, but when the tunable is enabled, we signal that an unused
dentry should be freed immediately, releasing its inode reference, and
so allowing that inode to be deleted if no longer in use.

Sponsored-by: Klara, Inc.
Sponsored-by: Fastmail Pty Ltd
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17746
This commit is contained in:
Rob Norris
2025-05-01 14:10:21 +10:00
committed by Brian Behlendorf
parent ab93b4b70e
commit ab8cc63c77
5 changed files with 95 additions and 0 deletions
+22
View File
@@ -2604,6 +2604,28 @@ frequently evicted and reloaded.
.Pp
This parameter is only available on Linux.
.
.It Sy zfs_delete_dentry Ns = Ns Sy 0 Ns | Ns 1 Pq int
Sets whether the kernel should free a dentry structure when it is no longer
required, or hold it in the dentry cache.
Intended for testing/debugging.
.
Since a dentry structure holds an inode reference, a cached dentry can "pin"
an inode in memory indefinitely, along with associated OpenZFS structures (See
.Sy zfs_delete_inode ) .
.Pp
The default value of
.Sy 0
instructs the kernel to cache entries and their associated inodes when they
are no longer directly referenced.
They will be reclaimed as part of the kernel's normal cache management
processes.
Setting it to
.Sy 1
will instruct the kernel to release directory entries and their inodes as soon
as they are no longer referenced by the filesystem.
.Pp
This parameter is only available on Linux.
.
.It Sy zio_taskq_batch_pct Ns = Ns Sy 80 Ns % Pq uint
Percentage of online CPUs which will run a worker thread for I/O.
These workers are responsible for I/O work such as compression, encryption,