]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Client: unlink dentry for inode with llref=0 29830/head
authorXiaoxi CHEN <xiaoxchen@ebay.com>
Thu, 25 Jul 2019 14:10:20 +0000 (07:10 -0700)
committerYan, Zheng <zyan@redhat.com>
Fri, 23 Aug 2019 00:56:10 +0000 (08:56 +0800)
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 <xiaoxchen@ebay.com>
(cherry picked from commit c9ff6ab4ebc0d44a07610f3391dfb92366f0277b)

 Conflicts:
src/client/Client.cc

src/client/Client.cc

index e9e862d37cdbe7ca930c98e1ecde1d72d98e3647..b83541cbd7121dd645362e2b7ecf05cb80177b1f 100644 (file)
@@ -5081,6 +5081,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 <<dendl;
 
   if (in->dir && !in->dir->dentries.empty()) {
     for (auto p = in->dir->dentries.begin();
@@ -5109,13 +5110,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) {
     set<Dentry*>::iterator q = in->dn_set.begin();
     while (q != in->dn_set.end()) {
-      Dentry *dn = *q++;
-      // FIXME: we play lots of unlink/link tricks when handling MDS replies,
-      //        so in->dn_set doesn't always reflect the state of kernel's dcache.
-      _schedule_invalidate_dentry_callback(dn, true);
+      Dentry *dn = *q;
+      ++q;
+      if( in->ll_ref > 0 && sched_inval) {
+       // FIXME: we play lots of unlink/link tricks when handling MDS replies,
+       //        so in->dn_set doesn't always reflect the state of kernel's dcache.
+       _schedule_invalidate_dentry_callback(dn, true);
+      }
       unlink(dn, true, true);
     }
   }