]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: move MDCache::eval_remote into StrayManager
authorYan, Zheng <zyan@redhat.com>
Thu, 8 Jun 2017 04:59:34 +0000 (12:59 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 8 Jun 2017 05:04:58 +0000 (13:04 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/StrayManager.cc
src/mds/StrayManager.h

index 837439a7eeb5f30c5d019725062c0a94f9e1273a..5d2cc0b85291c74c4b16ab2f9680d6c1c3092d37 100644 (file)
@@ -9467,41 +9467,6 @@ void MDCache::scan_stray_dir(dirfrag_t next)
   }
 }
 
-/**
- * If a remote dentry refers to an inode whose primary
- * dentry is a stray, then evaluate the inode for purging if
- * we have the auth copy, or migrate the stray to use if we
- * do not.
- */
-void MDCache::eval_remote(CDentry *remote_dn)
-{
-  assert(remote_dn);
-  dout(10) << __func__ << " " << *remote_dn << dendl;
-
-  CDentry::linkage_t *dnl = remote_dn->get_projected_linkage();
-  assert(dnl->is_remote());
-  CInode *in = dnl->get_inode();
-
-  if (!in) {
-    dout(20) << __func__ << ": no inode, cannot evaluate" << dendl;
-    return;
-  }
-
-  if (remote_dn->last != CEPH_NOSNAP) {
-    dout(20) << __func__ << ": snap dentry, cannot evaluate" << dendl;
-    return;
-  }
-
-  // refers to stray?
-  CDentry *primary_dn = in->get_projected_parent_dn();
-  assert(primary_dn != NULL);
-  if (primary_dn->get_dir()->get_inode()->is_stray()) {
-    stray_manager.eval_remote_stray(primary_dn, remote_dn);
-  } else {
-    dout(20) << __func__ << ": inode's primary dn not stray" << dendl;
-  }
-}
-
 void MDCache::fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Context *fin)
 {
   object_t oid = CInode::get_object_name(ino, frag_t(), "");
index ca3cdff76d9860e78d48b187e6219cb0557c0757..179d17c962e1d6da60a7814c8446d712a3848b5f 100644 (file)
@@ -196,6 +196,11 @@ public:
     stray_manager.notify_stray_created();
   }
 
+  void eval_remote(CDentry *dn)
+  {
+    stray_manager.eval_remote(dn);
+  }
+
   // -- client caps --
   uint64_t              last_cap_id;
   
@@ -970,7 +975,6 @@ public:
 
   // -- stray --
 public:
-  void eval_remote(CDentry *dn);
   void fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Context *fin);
   uint64_t get_num_strays() const { return stray_manager.get_num_strays(); }
 
index 34ba18679ec0315947b6310078db7b623867cb67..ea4b2025a8444f5f6f8654f3f6b354467aeb89ec 100644 (file)
@@ -535,7 +535,7 @@ bool StrayManager::_eval_stray(CDentry *dn, bool delay)
      * if we can do anything with them if we happen to have them in
      * cache.
      */
-    eval_remote_stray(dn, NULL);
+    _eval_stray_remote(dn, NULL);
     return false;
   }
 }
@@ -558,8 +558,37 @@ bool StrayManager::eval_stray(CDentry *dn, bool delay)
   return ret;
 }
 
-void StrayManager::eval_remote_stray(CDentry *stray_dn, CDentry *remote_dn)
+void StrayManager::eval_remote(CDentry *remote_dn)
 {
+  dout(10) << __func__ << " " << *remote_dn << dendl;
+
+  CDentry::linkage_t *dnl = remote_dn->get_projected_linkage();
+  assert(dnl->is_remote());
+  CInode *in = dnl->get_inode();
+
+  if (!in) {
+    dout(20) << __func__ << ": no inode, cannot evaluate" << dendl;
+    return;
+  }
+
+  if (remote_dn->last != CEPH_NOSNAP) {
+    dout(20) << __func__ << ": snap dentry, cannot evaluate" << dendl;
+    return;
+  }
+
+  // refers to stray?
+  CDentry *primary_dn = in->get_projected_parent_dn();
+  assert(primary_dn != NULL);
+  if (primary_dn->get_dir()->get_inode()->is_stray()) {
+    _eval_stray_remote(primary_dn, remote_dn);
+  } else {
+    dout(20) << __func__ << ": inode's primary dn not stray" << dendl;
+  }
+}
+
+void StrayManager::_eval_stray_remote(CDentry *stray_dn, CDentry *remote_dn)
+{
+  dout(20) << __func__ << " " << *stray_dn << dendl;
   assert(stray_dn != NULL);
   assert(stray_dn->get_dir()->get_inode()->is_stray());
   CDentry::linkage_t *stray_dnl = stray_dn->get_projected_linkage();
index a9bf3aa7840aca63aa98d57578790e27f59803ad..54629ee046bc127c97c89ce8455bb1f618672966 100644 (file)
@@ -119,6 +119,8 @@ class StrayManager
    */
   bool _eval_stray(CDentry *dn, bool delay=false);
 
+  void _eval_stray_remote(CDentry *stray_dn, CDentry *remote_dn);
+
   // My public interface is for consumption by MDCache
   public:
   explicit StrayManager(MDSRank *mds, PurgeQueue &purge_queue_);
@@ -144,11 +146,10 @@ class StrayManager
   void advance_delayed();
 
   /**
-   * When a metadata op touches a remote dentry that points to
-   * a stray, call in here to evaluate it for migration (move
-   * a stray residing on another MDS to this MDS) or reintegration
-   * (move a stray dentry's inode into a non-stray hardlink dentry and
-   * clean up the stray).
+   * Remote dentry potentially points to a stray. When it is touched,
+   * call in here to evaluate it for migration (move a stray residing
+   * on another MDS to this MDS) or reintegration (move a stray dentry's
+   * inode into a non-stray hardlink dentry and clean up the stray).
    *
    * @param stray_dn a stray dentry whose inode has been referenced
    *                 by a remote dentry
@@ -157,7 +158,7 @@ class StrayManager
    *                  as a hint for which remote to reintegrate into
    *                  if there are multiple remotes.
    */
-  void eval_remote_stray(CDentry *stray_dn, CDentry *remote_dn=NULL);
+  void eval_remote(CDentry *remote_dn);
 
   /**
    * Given a dentry within one of my stray directories,