]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: tighten conditions of calling rejoin_gather_finish() 22171/head
authorYan, Zheng <zyan@redhat.com>
Tue, 8 May 2018 03:32:01 +0000 (11:32 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 23 May 2018 08:06:11 +0000 (16:06 +0800)
Handle two cases:
1. mds receives all cache rejoin messages, then receives mdsmap that
   says mds cluster enters rejoining state.
2. when opening undef inodes/dirfrags, other mds restarts.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 0a38a499b86c0ee13aa0e783a8359bcce0876088)

src/mds/MDCache.cc

index 38fc78a9d8286305f714afad9afd2c77969cabf2..87d0bbf5a6a85cfab342bcf6813082abce177dbd 100644 (file)
@@ -4484,7 +4484,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
     }
   } else {
     // done?
-    if (rejoin_gather.empty()) {
+    if (rejoin_gather.empty() && rejoin_ack_gather.count(mds->get_nodeid())) {
       rejoin_gather_finish();
     } else {
       dout(7) << "still need rejoin from (" << rejoin_gather << ")" << dendl;
@@ -4492,14 +4492,6 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
   }
 }
 
-class C_MDC_RejoinGatherFinish : public MDCacheContext {
-public:
-  explicit C_MDC_RejoinGatherFinish(MDCache *c) : MDCacheContext(c) {}
-  void finish(int r) override {
-    mdcache->rejoin_gather_finish();
-  }
-};
-
 /*
  * rejoin_scour_survivor_replica - remove source from replica list on unmentioned objects
  *
@@ -4858,7 +4850,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
   // done?
   assert(rejoin_gather.count(from));
   rejoin_gather.erase(from);
-  if (rejoin_gather.empty()) {
+  if (rejoin_gather.empty() && rejoin_ack_gather.count(mds->get_nodeid())) {
     rejoin_gather_finish();
   } else {
     dout(7) << "still need rejoin from (" << rejoin_gather << ")" << dendl;
@@ -5174,6 +5166,7 @@ void MDCache::rejoin_gather_finish()
 {
   dout(10) << "rejoin_gather_finish" << dendl;
   assert(mds->is_rejoin());
+  assert(rejoin_ack_gather.count(mds->get_nodeid()));
 
   if (open_undef_inodes_dirfrags())
     return;
@@ -5187,7 +5180,6 @@ void MDCache::rejoin_gather_finish()
   rejoin_send_acks();
   
   // signal completion of fetches, rejoin_gather_finish, etc.
-  assert(rejoin_ack_gather.count(mds->get_nodeid()));
   rejoin_ack_gather.erase(mds->get_nodeid());
 
   // did we already get our acks too?
@@ -5818,7 +5810,15 @@ bool MDCache::open_undef_inodes_dirfrags()
   if (fetch_queue.empty())
     return false;
 
-  MDSGatherBuilder gather(g_ceph_context, new C_MDC_RejoinGatherFinish(this));
+  MDSGatherBuilder gather(g_ceph_context,
+      new MDSInternalContextWrapper(mds,
+       new FunctionContext([this](int r) {
+           if (rejoin_gather.empty())
+             rejoin_gather_finish();
+         })
+       )
+      );
+
   for (set<CDir*>::iterator p = fetch_queue.begin();
        p != fetch_queue.end();
        ++p) {