]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/MDBalancer.cc
import 15.2.5
[ceph.git] / ceph / src / mds / MDBalancer.cc
index a1b8508f54e32adcd8ea6677423d68190b59bfd8..76241bcb4bc37e25c6c4ff40ec27638a4810f2dc 100644 (file)
@@ -99,20 +99,23 @@ void MDBalancer::handle_export_pins(void)
     auto cur = it++;
     CInode *in = *cur;
     ceph_assert(in->is_dir());
+
+    in->check_pin_policy();
     mds_rank_t export_pin = in->get_export_pin(false);
     if (export_pin >= mds->mdsmap->get_max_mds()) {
-      dout(20) << " delay export pin on " << *in << dendl;
+      dout(20) << " delay export_pin=" << export_pin << " on " << *in << dendl;
       in->state_clear(CInode::STATE_QUEUEDEXPORTPIN);
       q.erase(cur);
 
       in->state_set(CInode::STATE_DELAYEDEXPORTPIN);
       mds->mdcache->export_pin_delayed_queue.insert(in);
       continue;
+    } else {
+      dout(20) << " executing export_pin=" << export_pin << " on " << *in << dendl;
     }
 
     bool remove = true;
-    auto&& dfls = in->get_dirfrags();
-    for (auto dir : dfls) {
+    for (auto&& dir : in->get_dirfrags()) {
       if (!dir->is_auth())
        continue;
 
@@ -128,22 +131,28 @@ void MDBalancer::handle_export_pins(void)
          mds->mdcache->try_subtree_merge(dir);
        }
       } else if (export_pin == mds->get_nodeid()) {
-       if (dir->state_test(CDir::STATE_CREATING) ||
-           dir->is_frozen() || dir->is_freezing()) {
+        if (dir->state_test(CDir::STATE_AUXSUBTREE)) {
+          ceph_assert(dir->is_subtree_root());
+        } else if (dir->state_test(CDir::STATE_CREATING) ||
+                  dir->is_frozen() || dir->is_freezing()) {
          // try again later
          remove = false;
          continue;
-       }
-       if (!dir->is_subtree_root()) {
+       } else if (!dir->is_subtree_root()) {
          dir->state_set(CDir::STATE_AUXSUBTREE);
          mds->mdcache->adjust_subtree_auth(dir, mds->get_nodeid());
          dout(10) << " create aux subtree on " << *dir << dendl;
-       } else if (!dir->state_test(CDir::STATE_AUXSUBTREE)) {
+       } else {
          dout(10) << " set auxsubtree bit on " << *dir << dendl;
          dir->state_set(CDir::STATE_AUXSUBTREE);
        }
       } else {
-       mds->mdcache->migrator->export_dir(dir, export_pin);
+        /* Only export a directory if it's non-empty. An empty directory will
+         * be sent back by the importer.
+         */
+        if (dir->get_num_head_items() > 0) {
+         mds->mdcache->migrator->export_dir(dir, export_pin);
+        }
        remove = false;
       }
     }
@@ -172,9 +181,12 @@ void MDBalancer::handle_export_pins(void)
                  dendl;
     }
 
-    if (export_pin >= 0 && export_pin < mds->mdsmap->get_max_mds() 
-       && export_pin != mds->get_nodeid()) {
-      mds->mdcache->migrator->export_dir(cd, export_pin);
+    if (export_pin >= 0 && export_pin < mds->mdsmap->get_max_mds()) {
+      if (export_pin == mds->get_nodeid()) {
+        cd->get_inode()->check_pin_policy();
+      } else {
+        mds->mdcache->migrator->export_dir(cd, export_pin);
+      }
     }
   }
 }