]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: optimize MDBalancer::find_exports()
authorYan, Zheng <zyan@redhat.com>
Wed, 6 Dec 2017 05:56:26 +0000 (13:56 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 10 Apr 2018 01:19:47 +0000 (09:19 +0800)
stop at subtree bounds; make freezing/frozen check more efficient.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDBalancer.cc

index 765acde9a104fbd53387eb64176fb2e540e57613..8b106a2c1eb5f4ce442fd3638841beb6bccacd21 100644 (file)
@@ -984,9 +984,12 @@ void MDBalancer::find_exports(CDir *dir,
                               double& have,
                               set<CDir*>& already_exporting)
 {
+  assert(dir->is_auth());
+
   double need = amount - have;
   if (need < amount * g_conf->mds_bal_min_start)
     return;   // good enough!
+
   double needmax = need * g_conf->mds_bal_need_max;
   double needmin = need * g_conf->mds_bal_need_min;
   double midchunk = need * g_conf->mds_bal_midchunk;
@@ -1005,15 +1008,19 @@ void MDBalancer::find_exports(CDir *dir,
     if (!in->is_dir()) continue;
 
     list<CDir*> dfls;
-    in->get_dirfrags(dfls);
+    in->get_nested_dirfrags(dfls);
     for (list<CDir*>::iterator p = dfls.begin();
         p != dfls.end();
         ++p) {
       CDir *subdir = *p;
-      if (!subdir->is_auth()) continue;
-      if (already_exporting.count(subdir)) continue;
+      if (already_exporting.count(subdir))
+       continue;
 
-      if (subdir->is_frozen() || subdir->is_freezing()) continue;  // can't export this right now!
+      // we know all ancestor dirfrags up to subtree root are not freezing or frozen.
+      // It's more efficient to use CDir::is_{freezing,frozen}_tree_root()
+      if (subdir->is_frozen_dir() || subdir->is_frozen_tree_root() ||
+         subdir->is_freezing_dir() || subdir->is_freezing_tree_root())
+       continue;  // can't export this right now!
 
       // how popular?
       double pop = subdir->pop_auth_subtree.meta_load(rebalance_time, mds->mdcache->decayrate);
@@ -1091,7 +1098,6 @@ void MDBalancer::find_exports(CDir *dir,
     if (have > needmin)
       return;
   }
-
 }
 
 void MDBalancer::hit_inode(const utime_t& now, CInode *in, int type, int who)