From 6cf1525e818d339fbcb96dddddb4cae46a57d147 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 8 May 2018 11:32:01 +0800 Subject: [PATCH] mds: tighten conditions of calling rejoin_gather_finish() 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" (cherry picked from commit 0a38a499b86c0ee13aa0e783a8359bcce0876088) --- src/mds/MDCache.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 21ea5c0306158..e768b315aad29 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -4598,7 +4598,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; @@ -4606,14 +4606,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 * @@ -4972,7 +4964,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; @@ -5315,6 +5307,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; @@ -5328,7 +5321,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? @@ -6010,7 +6002,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::iterator p = fetch_queue.begin(); p != fetch_queue.end(); ++p) { -- 2.39.5