* [PATCH] ceph: skip alias lookup when trimming non-directory caps
@ 2026-09-07 21:23 Max Kellermann
0 siblings, 0 replies; only message in thread
From: Max Kellermann @ 2026-09-07 21:23 UTC (permalink / raw)
To: idryomov, amarkuze, xiubo.li, ceph-devel, linux-kernel; +Cc: Max Kellermann
drop_negative_children() only does anything for directories; for
other inodes it returns true unconditionally. The d_find_any_alias()
and dput() pair around it is therefore pure overhead for regular
files: an extra `i_lock`, a dget()/dput(), and a ceph_d_delete()
check for zero-refcount dentries.
Only look up aliases for directories and prune other inodes
directly. d_prune_aliases() kills the same dentries either way.
Side effect: a non-directory inode without any alias now counts as
trimmed if the iterator holds the last reference. That is okay,
since with inode_just_drop it is evicted as soon as that reference
goes away.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/mds_client.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 085ae0cfb5f7..81cb1e9b9769 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2315,22 +2315,28 @@ static int trim_caps_cb(struct inode *inode, int mds, void *arg)
ceph_remove_cap(mdsc, cap, ci, true);
(*remaining)--;
} else {
- struct dentry *dentry;
+ int count;
+
/* try dropping referring dentries */
spin_unlock(&ci->i_ceph_lock);
- dentry = d_find_any_alias(inode);
- if (dentry && drop_negative_children(dentry)) {
- int count;
- dput(dentry);
- d_prune_aliases(inode);
- count = icount_read_once(inode);
- if (count == 1)
- (*remaining)--;
- doutc(cl, "%p %llx.%llx cap %p pruned, count now %d\n",
- inode, ceph_vinop(inode), cap, count);
- } else {
+ if (S_ISDIR(inode->i_mode)) {
+ struct dentry *dentry = d_find_any_alias(inode);
+ bool prune;
+
+ if (!dentry)
+ return 0;
+ prune = drop_negative_children(dentry);
dput(dentry);
+ if (!prune)
+ return 0;
}
+ /* The iterator's inode reference is sufficient to prune aliases. */
+ d_prune_aliases(inode);
+ count = icount_read_once(inode);
+ if (count == 1)
+ (*remaining)--;
+ doutc(cl, "%p %llx.%llx cap %p pruned, count now %d\n",
+ inode, ceph_vinop(inode), cap, count);
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-07 21:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07 21:23 [PATCH] ceph: skip alias lookup when trimming non-directory caps Max Kellermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®