ceph: skip alias lookup when trimming non-directory caps
PATCH 1/1 ceph: skip alias lookup when trimming non-directory caps
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.
--- fs/ceph/mds_client.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
fs/ceph/mds_client.c +18 -12
@@ -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 ; }
Signature · 1 line
2.47.3
Alex Markuze
maintainerHi 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.
Signature · 1 line
Alex Markuze
Quoted 9 lines · Alex Markuze
Hi Max,
NACK. Please respin.
The skip-alias idea is still worth doing. Please rebase it onto current
trim_caps_cb(after6b039a71d37a"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?
Signature · 8 lines
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