]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/MDCache.cc
import ceph nautilus 14.2.2
[ceph.git] / ceph / src / mds / MDCache.cc
index e51c52e55c53f84786a0d1b5a1444589e223a658..5417ca22253518eb2ce633ab560d71c61e31f325 100644 (file)
@@ -3708,16 +3708,25 @@ bool MDCache::expire_recursive(CInode *in, expiremap &expiremap)
 void MDCache::trim_unlinked_inodes()
 {
   dout(7) << "trim_unlinked_inodes" << dendl;
-  list<CInode*> q;
+  int count = 0;
+  vector<CInode*> q;
   for (auto &p : inode_map) {
     CInode *in = p.second;
     if (in->get_parent_dn() == NULL && !in->is_base()) {
       dout(7) << " will trim from " << *in << dendl;
       q.push_back(in);
     }
+
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
+  }
+
+  for (auto& in : q) {
+    remove_inode_recursive(in);
+
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
-  for (list<CInode*>::iterator p = q.begin(); p != q.end(); ++p)
-    remove_inode_recursive(*p);
 }
 
 /** recalc_auth_bits()
@@ -5492,9 +5501,9 @@ void MDCache::choose_lock_states_and_reconnect_caps()
 {
   dout(10) << "choose_lock_states_and_reconnect_caps" << dendl;
 
+  int count = 0;
   for (auto p : inode_map) {
     CInode *in = p.second;
-
     if (in->last != CEPH_NOSNAP)
       continue;
  
@@ -5514,6 +5523,9 @@ void MDCache::choose_lock_states_and_reconnect_caps()
       in->get(CInode::PIN_OPENINGSNAPPARENTS);
       rejoin_pending_snaprealms.insert(in);
     }
+
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
 }
 
@@ -5668,6 +5680,7 @@ void MDCache::export_remaining_imported_caps()
 
   stringstream warn_str;
 
+  int count = 0;
   for (auto p = cap_imports.begin(); p != cap_imports.end(); ++p) {
     warn_str << " ino " << p->first << "\n";
     for (auto q = p->second.begin(); q != p->second.end(); ++q) {
@@ -5680,7 +5693,8 @@ void MDCache::export_remaining_imported_caps()
       }
     }
 
-    mds->heartbeat_reset();
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
 
   for (map<inodeno_t, MDSContext::vec >::iterator p = cap_reconnect_waiters.begin();
@@ -6142,7 +6156,9 @@ void MDCache::reissue_all_caps()
 {
   dout(10) << "reissue_all_caps" << dendl;
 
+  int count = 0;
   for (auto &p : inode_map) {
+    int n = 1;
     CInode *in = p.second;
     if (in->is_head() && in->is_any_caps()) {
       // called by MDSRank::active_start(). There shouldn't be any frozen subtree.
@@ -6151,8 +6167,12 @@ void MDCache::reissue_all_caps()
        continue;
       }
       if (!mds->locker->eval(in, CEPH_CAP_LOCKS))
-       mds->locker->issue_caps(in);
+       n += mds->locker->issue_caps(in);
     }
+
+    if ((count % 1000) + n >= 1000)
+      mds->heartbeat_reset();
+    count += n;
   }
 }
 
@@ -6230,6 +6250,7 @@ void MDCache::_queued_file_recover_cow(CInode *in, MutationRef& mut)
 void MDCache::identify_files_to_recover()
 {
   dout(10) << "identify_files_to_recover" << dendl;
+  int count = 0;
   for (auto &p : inode_map) {
     CInode *in = p.second;
     if (!in->is_auth())
@@ -6268,6 +6289,9 @@ void MDCache::identify_files_to_recover()
     } else {
       rejoin_check_q.push_back(in);
     }
+
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
 }
 
@@ -11948,10 +11972,13 @@ void MDCache::force_readonly()
   mds->server->force_clients_readonly();
 
   // revoke write caps
+  int count = 0;
   for (auto &p : inode_map) {
     CInode *in = p.second;
     if (in->is_head())
       mds->locker->eval(in, CEPH_CAP_LOCKS);
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
 
   mds->mdlog->flush();
@@ -11961,7 +11988,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 +12004,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 +12031,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 +12060,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)