]> 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)
committerVicente Cheng <freeze.bilsted@gmail.com>
Tue, 30 Apr 2019 14:42:25 +0000 (14:42 +0000)
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 74a93a7723013254243ed78b0126d4e5e4c40afe..8347e1b74fe6f15ce04ddcfa4c247bd5a18f1217 100644 (file)
@@ -188,6 +188,8 @@ void MDBalancer::tick()
     send_heartbeat();
     num_bal_times--;
   }
+
+  mds->mdcache->show_subtrees(10, true);
 }
 
 
index e51c52e55c53f84786a0d1b5a1444589e223a658..4622bce6463712d2fdbddc7882feb9a90380e7de 100644 (file)
@@ -11961,7 +11961,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;
@@ -11977,6 +11977,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(ceph::dout::need_dynamic(dbl)) << "number of subtrees = " << subtrees.size() << "; not "
+               "printing subtrees" << dendl;
+    return;
+  }
+
   // root frags
   list<CDir*> basefrags;
   for (set<CInode*>::iterator p = base_inodes.begin();
@@ -11997,10 +12004,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;
@@ -12026,6 +12033,12 @@ void MDCache::show_subtrees(int dbl)
     }
   }
 
+  if (!force_print && depth > SUBTREES_DEPTH_THRESHOLD &&
+      !g_conf()->subsys.should_gather<ceph_subsys_mds, 25>()) {
+    dout(ceph::dout::need_dynamic(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 fe3d0e6e60b10b923f6b36d140118388c25917e9..0482b82bbdf9dbb06bb500d85105e2edb389f6bc 100644 (file)
@@ -305,6 +305,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;
@@ -1274,7 +1277,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() {
     ceph_assert(!inode_map.empty());