]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: dont print subtrees if they are too many/big
authorRishabh Dave <ridave@redhat.com>
Mon, 21 Jan 2019 10:06:57 +0000 (15:36 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 18 Apr 2019 11:55:59 +0000 (17:25 +0530)
Also, add an argument to force print subtrees and let
MDBalancer::tick() always print subtrees.

Fixes: https://tracker.ceph.com/issues/37726
Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 50d28ec4f842670fb96ab3b0d2b37a9c2e282236)

src/mds/MDBalancer.cc
src/mds/MDCache.cc
src/mds/MDCache.h

index d5c026c327f9f8cae53f2d8a9763086542884903..013901c77a3bb65950ccef694916d1a68ae1c75d 100644 (file)
@@ -188,6 +188,8 @@ void MDBalancer::tick()
     send_heartbeat();
     num_bal_times--;
   }
+
+  mds->mdcache->show_subtrees(10, true);
 }
 
 
index 6a44598f1769a11d863c9962e27eb9f714b8217d..ecd4ab8d618de88d851fa367df22cbf4ce3a3b36 100644 (file)
@@ -11965,7 +11965,7 @@ void MDCache::force_readonly()
 // ==============================================================
 // debug crap
 
-void MDCache::show_subtrees(int dbl)
+void MDCache::show_subtrees(int dbl, bool force_print)
 {
   if (g_conf->mds_thrash_exports)
     dbl += 15;
@@ -11980,6 +11980,13 @@ void MDCache::show_subtrees(int dbl)
     return;
   }
 
+  if (!force_print && subtrees.size() > SUBTREES_COUNT_THRESHOLD &&
+      !g_conf->subsys.should_gather(ceph_subsys_mds, 25)) {
+    dout(dbl) << "number of subtrees = " << subtrees.size() << "; not "
+               "printing subtrees" << dendl;
+    return;
+  }
+
   // root frags
   list<CDir*> basefrags;
   for (set<CInode*>::iterator p = base_inodes.begin();
@@ -12000,10 +12007,10 @@ void MDCache::show_subtrees(int dbl)
 
   set<CDir*> subtrees_seen;
 
-  int depth = 0;
+  unsigned int depth = 0;
   while (!q.empty()) {
     CDir *dir = q.front().first;
-    int d = q.front().second;
+    unsigned int d = q.front().second;
     q.pop_front();
 
     if (subtrees.count(dir) == 0) continue;
@@ -12029,6 +12036,12 @@ void MDCache::show_subtrees(int dbl)
     }
   }
 
+  if (!force_print && depth > SUBTREES_DEPTH_THRESHOLD &&
+      !g_conf->subsys.should_gather(ceph_subsys_mds, 25)) {
+    dout(dbl) << "max depth among subtrees = " << depth << "; not printing "
+               "subtrees" << dendl;
+    return;
+  }
 
   // print tree
   for (list<CDir*>::iterator p = basefrags.begin(); p != basefrags.end(); ++p) 
index 2d1e8463aa963b004565910503de5e7e7a739d8e..b288534802a0b112804af611a4c8643620d2de01 100644 (file)
@@ -304,6 +304,9 @@ public:
 
 
   // -- subtrees --
+private:
+  static const unsigned int SUBTREES_COUNT_THRESHOLD = 5;
+  static const unsigned int SUBTREES_DEPTH_THRESHOLD = 5;
 protected:
   /* subtree keys and each tree's non-recursive nested subtrees (the "bounds") */
   map<CDir*,set<CDir*> > subtrees;
@@ -1204,7 +1207,7 @@ public:
   // == crap fns ==
  public:
   void show_cache();
-  void show_subtrees(int dbl=10);
+  void show_subtrees(int dbl=10, bool force_print=false);
 
   CInode *hack_pick_random_inode() {
     assert(!inode_map.empty());