]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: reset heartbeat inside big loop 28406/head
authorYan, Zheng <zyan@redhat.com>
Wed, 5 Jun 2019 10:05:15 +0000 (18:05 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 5 Jun 2019 10:07:00 +0000 (18:07 +0800)
Fixes: https://tracker.ceph.com/issues/40171
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/Locker.cc
src/mds/Locker.h
src/mds/MDCache.cc

index a4776c00fa3bf342dd73f9070d81cdc3a033bfd7..31d941de892453d17c30de7f5b829fcf8ca7319d 100644 (file)
@@ -1966,7 +1966,7 @@ void Locker::issue_caps_set(set<CInode*>& inset)
     issue_caps(*p);
 }
 
-bool Locker::issue_caps(CInode *in, Capability *only_cap)
+int Locker::issue_caps(CInode *in, Capability *only_cap)
 {
   // allowed caps are determined by the lock mode.
   int all_allowed = in->get_caps_allowed_by_type(CAP_ANY);
@@ -2091,7 +2091,7 @@ bool Locker::issue_caps(CInode *in, Capability *only_cap)
       break;
   }
 
-  return (nissued == 0);  // true if no re-issued, no callbacks
+  return nissued;
 }
 
 void Locker::issue_truncate(CInode *in)
index de45423b53f99222798746846ea6355028e9bfc8..7ed6e7a1dc643c94e353976d5ecc1221f87e7d03 100644 (file)
@@ -240,7 +240,7 @@ public:
 public:
   version_t issue_file_data_version(CInode *in);
   Capability* issue_new_caps(CInode *in, int mode, Session *session, SnapRealm *conrealm, bool is_replay);
-  bool issue_caps(CInode *in, Capability *only_cap=0);
+  int issue_caps(CInode *in, Capability *only_cap=0);
   void issue_caps_set(std::set<CInode*>& inset);
   void issue_truncate(CInode *in);
   void revoke_stale_caps(Session *session);
index 15913a35d13d080ad0e0e627a5aa776056f836f8..1c2dc61c3f7b748e1e60c5fe2c7244f6d1e407e9 100644 (file)
@@ -3685,16 +3685,23 @@ 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();
   }
 }
 
@@ -5468,9 +5475,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;
  
@@ -5490,6 +5497,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();
   }
 }
 
@@ -5644,6 +5654,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) {
@@ -5658,7 +5669,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();
@@ -6128,7 +6140,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.
@@ -6137,8 +6151,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;
   }
 }
 
@@ -6216,6 +6234,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())
@@ -6254,6 +6273,9 @@ void MDCache::identify_files_to_recover()
     } else {
       rejoin_check_q.push_back(in);
     }
+
+    if (!(++count % 1000))
+      mds->heartbeat_reset();
   }
 }
 
@@ -11898,10 +11920,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();