From: Rishabh Dave Date: Mon, 21 Jan 2019 10:06:57 +0000 (+0530) Subject: mds: dont print subtrees if they are too many/big X-Git-Tag: v12.2.13~225^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c88284ceaf89bef947ec8373dac5f54018e7104;p=ceph.git mds: dont print subtrees if they are too many/big 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 (cherry picked from commit 50d28ec4f842670fb96ab3b0d2b37a9c2e282236) --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index d5c026c327f9..013901c77a3b 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -188,6 +188,8 @@ void MDBalancer::tick() send_heartbeat(); num_bal_times--; } + + mds->mdcache->show_subtrees(10, true); } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 6a44598f1769..ecd4ab8d618d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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 basefrags; for (set::iterator p = base_inodes.begin(); @@ -12000,10 +12007,10 @@ void MDCache::show_subtrees(int dbl) set 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::iterator p = basefrags.begin(); p != basefrags.end(); ++p) diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 2d1e8463aa96..b288534802a0 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -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 > 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());