]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: reset heartbeat map at potential time-consuming places
authorYan, Zheng <zyan@redhat.com>
Wed, 11 Jul 2018 09:30:39 +0000 (17:30 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 6 Aug 2018 03:31:26 +0000 (11:31 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Fixes: http://tracker.ceph.com/issues/26858
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/Migrator.cc
src/mds/OpenFileTable.cc

index 2997baf719b6e6e2855cd433fd90f760b8281103..4f056de08952893a2d230c92d3e78efd92e3fec5 100644 (file)
@@ -1947,7 +1947,7 @@ void MDSRankDispatcher::handle_mds_map(
       MDSInternalContextBase::vec ls;
       ls.swap(p->second);
       waiting_for_mdsmap.erase(p++);
-      finish_contexts(g_ceph_context, ls);
+      queue_waiters(ls);
     }
   }
 
index 2b8807ae283ec3d46cf08d5f5bb1a8a264d0f410..dd6fba923deac495abebf24f74660c2024af4bf2 100644 (file)
@@ -307,6 +307,12 @@ class MDSRank {
       std::copy(v.begin(), v.end(), std::back_inserter(finished_queue));
       progress_thread.signal();
     }
+    void queue_waiters_front(MDSInternalContextBase::vec& ls) {
+      MDSInternalContextBase::vec v;
+      v.swap(ls);
+      std::copy(v.rbegin(), v.rend(), std::front_inserter(finished_queue));
+      progress_thread.signal();
+    }
 
     MDSRank(
         mds_rank_t whoami_,
index 22c8de969112ef1a5f121f106619cdb602680567..df19531a7e0c5ffd2bb601384be731ba5b0d16da 100644 (file)
@@ -2593,6 +2593,15 @@ void Migrator::import_remove_pins(CDir *dir, set<CDir*>& bounds)
   }
 }
 
+class C_MDC_QueueContexts : public MigratorContext {
+public:
+  MDSInternalContextBase::vec contexts;
+  C_MDC_QueueContexts(Migrator *m) : MigratorContext(m) {}
+  void finish(int r) override {
+    // execute contexts immediately after 'this' context
+    get_mds()->queue_waiters_front(contexts);
+  }
+};
 
 /*
  * note: this does teh full work of reversing and import and cleaning up
@@ -2620,7 +2629,7 @@ void Migrator::import_reverse(CDir *dir)
 
   cache->adjust_subtree_auth(dir, stat.peer);
 
-  auto fin = new C_ContextsBase<MDSInternalContextBase, MDSInternalContextGather, MDSInternalContextBase::vec>(g_ceph_context);
+  auto fin = new C_MDC_QueueContexts(this);
   if (!dir->get_inode()->is_auth() &&
       !dir->get_inode()->has_subtree_root_dirfrag(mds->get_nodeid())) {
     dir->get_inode()->clear_scatter_dirty();
index d3dae5ba4f759feb345fc0399d29b1fa480859ca..86d5579274ffd43a2685d7214a4e891db38a402c 100644 (file)
@@ -1057,10 +1057,14 @@ void OpenFileTable::_prefetch_dirfrags()
   }
 
   MDSGatherBuilder gather(g_ceph_context);
+  int num_opening_dirfrags = 0;
   for (auto dir : fetch_queue) {
     if (dir->state_test(CDir::STATE_REJOINUNDEF))
       assert(dir->get_inode()->dirfragtree.is_leaf(dir->get_frag()));
     dir->fetch(gather.new_sub());
+
+    if (!(++num_opening_dirfrags % 1000))
+      mds->heartbeat_reset();
   }
 
   auto finish_func = [this](int r) {
@@ -1123,6 +1127,9 @@ void OpenFileTable::_prefetch_inodes()
 
     num_opening_inodes++;
     mdcache->open_ino(it.first, pool, new C_OFT_OpenInoFinish(this, it.first), false);
+
+    if (!(num_opening_inodes % 1000))
+      mds->heartbeat_reset();
   }
 
   _open_ino_finish(inodeno_t(0), 0);