From d885f3c87d6caf45fa0d2f5208f236abd99ee78a Mon Sep 17 00:00:00 2001 From: Xiaoxi CHEN Date: Thu, 25 Jul 2019 07:10:20 -0700 Subject: [PATCH] Client: unlink dentry for inode with llref=0 when client get notification from MDS that a file has been deleted(via getting CEPH_CAP_LINK_SHARED cap for inode with nlink = 0), if the client hasnt touch the inode in the past, the ll_ref will be zero. In previous code, we only call Client::unlink when ll_ref > 0, which is wrong and will leave the dn in cache, keeping the caps and resulting the inode stays in stray till the dn cache is dropped by kernel. Under certain workload(write intensive and rotate intensive), this issue can cause stray stacking to 100k+ and causeing huge space "leaking". Fixes: http://tracker.ceph.com/issues/40960 Signed-off-by: Xiaoxi CHEN (cherry picked from commit c9ff6ab4ebc0d44a07610f3391dfb92366f0277b) --- src/client/Client.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 0e79823c5980a..83999e9d1b553 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5102,6 +5102,7 @@ void Client::_schedule_invalidate_dentry_callback(Dentry *dn, bool del) void Client::_try_to_trim_inode(Inode *in, bool sched_inval) { int ref = in->get_num_ref(); + ldout(cct, 5) << __func__ << " in " << *in <dir && !in->dir->dentries.empty()) { for (auto p = in->dir->dentries.begin(); @@ -5130,14 +5131,16 @@ void Client::_try_to_trim_inode(Inode *in, bool sched_inval) --ref; } - if (ref > 0 && in->ll_ref > 0 && sched_inval) { + if (ref > 0) { auto q = in->dentries.begin(); while (q != in->dentries.end()) { Dentry *dn = *q; ++q; - // FIXME: we play lots of unlink/link tricks when handling MDS replies, - // so in->dentries doesn't always reflect the state of kernel's dcache. - _schedule_invalidate_dentry_callback(dn, true); + if( in->ll_ref > 0 && sched_inval) { + // FIXME: we play lots of unlink/link tricks when handling MDS replies, + // so in->dentries doesn't always reflect the state of kernel's dcache. + _schedule_invalidate_dentry_callback(dn, true); + } unlink(dn, true, true); } } -- 2.39.5