]> git.apps.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)
committerNathan Cutler <ncutler@suse.com>
Wed, 16 Oct 2019 10:57:35 +0000 (12:57 +0200)
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)

Conflicts:
    src/mds/MDCache.cc
- g_conf

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

index 9553bafe40e0cde78465e151168ed82272f159b7..582878905e0b090f0f8ab7ec126e1892ff907392 100644 (file)
@@ -205,6 +205,8 @@ void MDBalancer::tick()
     send_heartbeat();
     num_bal_times--;
   }
+
+  mds->mdcache->show_subtrees(10, true);
 }
 
 
index 586173fbdac93af37f0304d50153a1d530e87757..0df26425408f347bbfc350ad4dcbb5dc00745b8e 100644 (file)
@@ -12221,7 +12221,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;
@@ -12237,6 +12237,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();
@@ -12257,10 +12264,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;
@@ -12286,6 +12293,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 564af377ae75f8374e42d88982c0a7f42fc1d555..64f3ef61274b45e6d54e3e09dbe1c58b88cb34fb 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;
@@ -1234,7 +1237,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());