]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: avoid blindly removing dentries
authorSage Weil <sage@inktank.com>
Fri, 17 May 2013 19:12:15 +0000 (12:12 -0700)
committerYan, Zheng <zheng.z.yan@intel.com>
Wed, 7 May 2014 02:06:52 +0000 (10:06 +0800)
MetaRequests may have references to these dentries.  Instead of removing
them and tearing down the directory, just unlink them from the inodes.

We could be a bit smarter here if we looked at the reference count, but
this works too.

Signed-off-by: Sage Weil <sage@inktank.com>
src/client/Client.cc

index 7337563d063a910b4147e3a516a8d885c91b33d2..deff09370fde6e0ac6e53e98c751fbada4659a11 100644 (file)
@@ -726,10 +726,14 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from,
     in->flags |= I_COMPLETE;
     if (in->dir) {
       ldout(cct, 10) << " dir is open on empty dir " << in->ino << " with "
-                    << in->dir->dentry_map.size() << " entries, tearing down" << dendl;
-      while (!in->dir->dentry_map.empty())
+                    << in->dir->dentry_map.size() << " entries, marking all dentries null" << dendl;
+      for (map<string, Dentry*>::iterator p = in->dir->dentry_map.begin();
+          p != in->dir->dentry_map.end();
+          ++p) {
        unlink(in->dir->dentry_map.begin()->second, true, true);
-      close_dir(in->dir);
+      }
+      if (in->dir->dentry_map.empty())
+       close_dir(in->dir);
     }
   }
 
@@ -3799,7 +3803,7 @@ void Client::_invalidate_inode_parents(Inode *in)
     // 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, false);
+    unlink(dn, true, true);
   }
 }