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: v14.2.2~94^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b8586ef74015187da7a2c04f3e037ba0a2f633a1;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 74a93a772301..8347e1b74fe6 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 e51c52e55c53..4622bce64637 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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()) { + dout(ceph::dout::need_dynamic(dbl)) << "number of subtrees = " << subtrees.size() << "; not " + "printing subtrees" << dendl; + return; + } + // root frags list basefrags; for (set::iterator p = base_inodes.begin(); @@ -11997,10 +12004,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; @@ -12026,6 +12033,12 @@ void MDCache::show_subtrees(int dbl) } } + if (!force_print && depth > SUBTREES_DEPTH_THRESHOLD && + !g_conf()->subsys.should_gather()) { + dout(ceph::dout::need_dynamic(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 fe3d0e6e60b1..0482b82bbdf9 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -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 > 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());