* [PATCH] ceph: skip alias lookup when trimming non-directory caps
@ 2026-09-07 21:23 Max Kellermann
2026-09-09 10:38 ` Alex Markuze
0 siblings, 1 reply; 3+ messages 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 related [flat|nested] 3+ messages in thread
* Re: ceph: skip alias lookup when trimming non-directory caps
2026-09-07 21:23 [PATCH] ceph: skip alias lookup when trimming non-directory caps Max Kellermann
@ 2026-09-09 10:38 ` Alex Markuze
2026-09-09 10:44 ` Max Kellermann
0 siblings, 1 reply; 3+ messages in thread
From: Alex Markuze @ 2026-09-09 10:38 UTC (permalink / raw)
To: Max Kellermann; +Cc: ceph-devel
Hi Max,
NACK. Please respin.
The skip-alias idea is still worth doing. Please rebase it onto
current trim_caps_cb (after 6b039a71d37a "ceph: keep the inode, not
the name, when a dentry lease expires") and keep that later prune
path intact.
--
Alex Markuze
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ceph: skip alias lookup when trimming non-directory caps
2026-09-09 10:38 ` Alex Markuze
@ 2026-09-09 10:44 ` Max Kellermann
0 siblings, 0 replies; 3+ messages in thread
From: Max Kellermann @ 2026-09-09 10:44 UTC (permalink / raw)
To: Alex Markuze; +Cc: ceph-devel
On Wed, Sep 9, 2026 at 12:38 PM Alex Markuze <amarkuze@redhat.com> wrote:
>
> Hi Max,
>
> NACK. Please respin.
>
> The skip-alias idea is still worth doing. Please rebase it onto
> current trim_caps_cb (after 6b039a71d37a "ceph: keep the inode, not
> the name, when a dentry lease expires") and keep that later prune
> path intact.
I have no idea what that means. What is worth doing?
--
Max Kellermann
Principal Architect
Hosting Technology
cm4all | Im Mediapark 6a | 50670 Köln | Germany
General information about the company can be found here:
https://www.cm4all.com/impressum
A member of the IONOS Group
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-09 10:44 UTC | newest]
Thread overview: 3+ messages (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
2026-09-09 10:38 ` Alex Markuze
2026-09-09 10:44 ` Max Kellermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox