]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: remove unnecessary check for parent pins
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 4 May 2017 02:42:57 +0000 (22:42 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 4 May 2017 16:59:43 +0000 (12:59 -0400)
With Zheng's help, now that the code has captured all the paths where an inode
should be checked for export pins, we don't need to look at parents anymore.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/CInode.cc
src/mds/Migrator.cc

index 4eade9fce5f799075b521145e4c47d48993ba5e9..9a68bf11884019ef58ac0576b465dc68ada3977b 100644 (file)
@@ -4419,68 +4419,42 @@ void CInode::maybe_export_pin()
   if (g_conf->mds_bal_export_pin && is_dir()) {
     dout(20) << "maybe_export_pin " << *this << dendl;
     mds_rank_t pin = get_projected_inode()->export_pin;
-    if (pin == MDS_RANK_NONE) {
-      if (!mdcache->export_pin_queue.count(this)) {
-        /* Try to find farthest full auth parent fragment which is pinned
-         * elsewhere.  There cannot be a break in the authority chain of
-         * directories, otherwise this inode itself will not be exported.
-         */
-        CInode *auth_last = this; /* N.B. we may not be full auth for any fragments of this inode, but adding it to the queue is harmless. */
-        bool auth_barrier = false;
-        for (CDir *cd = get_projected_parent_dir(); cd && !cd->inode->is_base() && !cd->inode->is_system(); cd = cd->inode->get_projected_parent_dir()) {
-          if (cd->is_full_dir_auth() && !auth_barrier) {
-            auth_last = cd->inode;
+    if (pin == mdcache->mds->get_nodeid()) {
+      for (auto it = dirfrags.begin(); it != dirfrags.end(); it++) {
+        CDir *cd = it->second;
+        if (cd->state_test(CDir::STATE_AUXSUBTREE)) continue;
+        CDir *subtree = mdcache->get_subtree_root(cd);
+        if (!subtree) continue;
+        if (subtree->is_ambiguous_auth()) {
+          subtree->add_waiter(MDSCacheObject::WAIT_SINGLEAUTH, new C_CInode_ExportPin(this));
+          dout(15) << "aux subtree pin of " << *cd << " delayed for single auth on subtree " << *subtree << dendl;
+        } else if (subtree->is_auth()) {
+          assert(cd->is_auth());
+          if (subtree->is_frozen() || subtree->is_freezing()) {
+            subtree->add_waiter(MDSCacheObject::WAIT_UNFREEZE, new C_CInode_ExportPin(this));
+            dout(15) << "aux subtree pin of " << *cd << " delayed for unfreeze on subtree " << *subtree << dendl;
           } else {
-            auth_barrier = true;
-          }
-          pin = cd->inode->get_projected_inode()->export_pin;
-          if (pin != MDS_RANK_NONE) {
-            if (pin != mdcache->mds->get_nodeid()) {
-              dout(20) << "adding ancestor to export_pin_queue " << *auth_last << dendl;
-              mdcache->export_pin_queue.insert(auth_last);
-            }
-            break;
+            cd->state_set(CDir::STATE_AUXSUBTREE);
+            mdcache->adjust_subtree_auth(cd, mdcache->mds->get_nodeid());
+            dout(15) << "aux subtree pinned " << *cd << dendl;
           }
+        } else {
+          assert(!cd->is_auth());
+          dout(15) << "not setting aux subtree pin for " << *cd << " because not auth" << dendl;
         }
       }
-    } else {
-      if (pin == mdcache->mds->get_nodeid()) {
-        for (auto it = dirfrags.begin(); it != dirfrags.end(); it++) {
-          CDir *cd = it->second;
-          if (cd->state_test(CDir::STATE_AUXSUBTREE)) continue;
-          CDir *subtree = mdcache->get_subtree_root(cd);
-          if (!subtree) continue;
-          if (subtree->is_ambiguous_auth()) {
-            subtree->add_waiter(MDSCacheObject::WAIT_SINGLEAUTH, new C_CInode_ExportPin(this));
-            dout(15) << "aux subtree pin of " << *cd << " delayed for single auth on subtree " << *subtree << dendl;
-          } else if (subtree->is_auth()) {
-            assert(cd->is_auth());
-            if (subtree->is_frozen() || subtree->is_freezing()) {
-              subtree->add_waiter(MDSCacheObject::WAIT_UNFREEZE, new C_CInode_ExportPin(this));
-              dout(15) << "aux subtree pin of " << *cd << " delayed for unfreeze on subtree " << *subtree << dendl;
-            } else {
-              cd->state_set(CDir::STATE_AUXSUBTREE);
-              mdcache->adjust_subtree_auth(cd, mdcache->mds->get_nodeid());
-              dout(15) << "aux subtree pinned " << *cd << dendl;
-            }
-          } else {
-            assert(!cd->is_auth());
-            dout(15) << "not setting aux subtree pin for " << *cd << " because not auth" << dendl;
-          }
-        }
-      } else {
-        for (auto it = dirfrags.begin(); it != dirfrags.end(); it++) {
-          CDir *cd = it->second;
-          if (cd->is_auth() && cd->state_test(CDir::STATE_AUXSUBTREE)) {
-            assert(!(cd->is_frozen() || cd->is_freezing()));
-            assert(!cd->state_test(CDir::STATE_EXPORTBOUND));
-            cd->state_clear(CDir::STATE_AUXSUBTREE); /* merge will happen eventually */
-            dout(15) << "cleared aux subtree pin " << *cd << dendl;
-          }
+    } else if (pin != MDS_RANK_NONE) {
+      for (auto it = dirfrags.begin(); it != dirfrags.end(); it++) {
+        CDir *cd = it->second;
+        if (cd->is_auth() && cd->state_test(CDir::STATE_AUXSUBTREE)) {
+          assert(!(cd->is_frozen() || cd->is_freezing()));
+          assert(!cd->state_test(CDir::STATE_EXPORTBOUND));
+          cd->state_clear(CDir::STATE_AUXSUBTREE); /* merge will happen eventually */
+          dout(15) << "cleared aux subtree pin " << *cd << dendl;
         }
-        dout(20) << "adding to export_pin_queue " << *this << dendl;
-        mdcache->export_pin_queue.insert(this);
       }
+      dout(20) << "adding to export_pin_queue " << *this << dendl;
+      mdcache->export_pin_queue.insert(this);
     }
   }
 }
index d155169c9f7999bfe78be9d9f5f3d92b8b34c27d..41bc508d8f4c009c539234b7dfaf5e9469c8c2d8 100644 (file)
@@ -2943,8 +2943,6 @@ void Migrator::decode_import_inode(CDentry *dn, bufferlist::iterator& blp,
   in->add_replica(oldauth, CInode::EXPORT_NONCE);
   if (in->is_replica(mds->get_nodeid()))
     in->remove_replica(mds->get_nodeid());
-
-  in->maybe_export_pin();
 }
 
 void Migrator::decode_import_inode_caps(CInode *in, bool auth_cap,