From: Yan, Zheng Date: Mon, 25 May 2020 13:48:23 +0000 (+0800) Subject: mds: cleanup uncommitted fragments before mds goes to active X-Git-Tag: v14.2.11~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8beb0a9fdee4e04d371664e0d63be6e2f9a38c21;p=ceph.git mds: cleanup uncommitted fragments before mds goes to active Fixes: https://tracker.ceph.com/issues/45699 Signed-off-by: "Yan, Zheng" (cherry picked from commit 77eb368d2d35f2418875227fff9a34b5ef15a290) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 68a3299ae53..acf57977e1a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -11959,6 +11959,12 @@ void MDCache::rollback_uncommitted_fragment(dirfrag_t basedirfrag, frag_vec_t&& } } +void MDCache::wait_for_uncommitted_fragments(MDSGather *gather) +{ + for (auto& p : uncommitted_fragments) + p.second.waiters.push_back(gather->new_sub()); +} + void MDCache::rollback_uncommitted_fragments() { dout(10) << "rollback_uncommitted_fragments: " << uncommitted_fragments.size() << " pending" << dendl; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 5b0b361b4ff..abe7e624855 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -1234,12 +1234,16 @@ private: public: void wait_for_uncommitted_fragment(dirfrag_t dirfrag, MDSContext *c) { - ceph_assert(uncommitted_fragments.count(dirfrag)); - uncommitted_fragments[dirfrag].waiters.push_back(c); + uncommitted_fragments.at(dirfrag).waiters.push_back(c); } + bool is_any_uncommitted_fragment() const { + return !uncommitted_fragments.empty(); + } + void wait_for_uncommitted_fragments(MDSGather *gather); + void rollback_uncommitted_fragments(); + void split_dir(CDir *dir, int byn); void merge_dir(CInode *diri, frag_t fg); - void rollback_uncommitted_fragments(); void find_stale_fragment_freeze(); void fragment_freeze_inc_num_waiters(CDir *dir); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index af108a99984..c47bd464ada 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -1916,6 +1916,14 @@ void MDSRank::rejoin_done() mdcache->show_subtrees(); mdcache->show_cache(); + if (mdcache->is_any_uncommitted_fragment()) { + dout(1) << " waiting for uncommitted fragments" << dendl; + MDSGatherBuilder gather(g_ceph_context, new C_MDS_VoidFn(this, &MDSRank::rejoin_done)); + mdcache->wait_for_uncommitted_fragments(gather.get()); + gather.activate(); + return; + } + // funny case: is our cache empty? no subtrees? if (!mdcache->is_subtrees()) { if (whoami == 0) {