]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: streamline stray checks with helper
authorSage Weil <sage@newdream.net>
Mon, 5 Apr 2010 17:26:42 +0000 (10:26 -0700)
committerSage Weil <sage@newdream.net>
Mon, 5 Apr 2010 17:26:42 +0000 (10:26 -0700)
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/MDCache.h

index 0bd1b929dc3c827c132dc0b36faec3a76db0796f..d65d2afae404e7f5189b7d272d956037cd0e60a2 100644 (file)
@@ -1074,15 +1074,7 @@ void Locker::file_update_finish(CInode *in, Mutation *mut, bool share, client_t
     share_inode_max_size(in);
 
   // unlinked stray?  may need to purge (e.g., after all caps are released)
-  if (in->inode.nlink == 0 &&
-      in->get_parent_dn() &&
-      in->get_parent_dn()->get_dir()->get_inode()->is_stray() &&
-      !in->is_any_caps()) {
-    if (!in->is_auth())
-      mdcache->touch_dentry_bottom(in->get_parent_dn());  // move to bottom of lru so that we trim quickly!
-    else if (!in->is_replicated())
-      mdcache->eval_stray(in->get_parent_dn());
-  }
+  mdcache->maybe_eval_stray(in);
 }
 
 Capability* Locker::issue_new_caps(CInode *in,
index 44ed0698f0d76ac00f0f92ca6d5e7738f979c3b4..fcff3d33c686955759f47bada9e536c849243639 100644 (file)
@@ -5254,11 +5254,7 @@ void MDCache::inode_remove_replica(CInode *in, int from)
   if (in->nestlock.remove_replica(from)) mds->locker->eval_gather(&in->nestlock);
 
   // trim?
-  if (in->inode.nlink == 0 &&
-      in->get_parent_dn() &&
-      in->get_parent_dn()->get_dir()->get_inode()->is_stray() &&
-      !in->is_any_caps())
-    eval_stray(in->get_parent_dn());
+  maybe_eval_stray(in);
 }
 
 void MDCache::dentry_remove_replica(CDentry *dn, int from)
@@ -5356,16 +5352,7 @@ void MDCache::remove_client_cap(CInode *in, client_t client)
   
   mds->locker->eval(in, CEPH_CAP_LOCKS);
 
-  // unlinked stray?  may need to purge (e.g., after all caps are released)
-  if (in->inode.nlink == 0 &&
-      in->get_parent_dn() &&
-      in->get_parent_dn()->get_dir()->get_inode()->is_stray() &&
-      !in->is_any_caps()) {
-    if (!in->is_auth())
-      touch_dentry_bottom(in->get_parent_dn());  // move to bottom of lru so that we trim quickly!
-    else if (!in->is_replicated())
-      eval_stray(in->get_parent_dn());
-  }
+  maybe_eval_stray(in);
 }
 
 
@@ -6879,7 +6866,14 @@ void MDCache::eval_stray(CDentry *dn)
   CInode *in = dnl->get_inode();
   assert(in);
 
-  if (!dn->is_auth()) return;  // has to be mine
+  assert(dn->get_dir()->get_inode()->is_stray());
+
+  if (!dn->is_auth()) {
+    // has to be mine
+    // move to bottom of lru so that we trim quickly!
+    touch_dentry_bottom(dn);
+    return;
+  }
 
   // purge?
   if (in->inode.nlink == 0) {
index 8deab3a870862af2013853869f74da5fbc3c9dc6..3451fbbf2bbdddcfb9c7605e919a2c4ab8272a46 100644 (file)
@@ -984,6 +984,16 @@ public:
 public:
   void eval_stray(CDentry *dn);
   void eval_remote(CDentry *dn);
+
+  void maybe_eval_stray(CInode *in) {
+    if (in->inode.nlink > 0 || in->is_base())
+      return;
+    CDentry *dn = in->get_projected_parent_dn();
+    if (dn->get_projected_linkage()->is_primary() &&
+       dn->get_dir()->get_inode()->is_stray() &&
+       !dn->is_replicated())
+      eval_stray(dn);
+  }
 protected:
   void purge_stray(CDentry *dn);
   void _purge_stray_purged(CDentry *dn);