]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: cleanup uncommitted fragments before mds goes to active 35397/head
authorYan, Zheng <zyan@redhat.com>
Mon, 25 May 2020 13:48:23 +0000 (21:48 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 4 Jun 2020 13:55:21 +0000 (15:55 +0200)
Fixes: https://tracker.ceph.com/issues/45699
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 77eb368d2d35f2418875227fff9a34b5ef15a290)

src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSRank.cc

index 68a3299ae53a55fc1640c986ab08c9510757b748..acf57977e1ad3106c43b6d218564197ccce3a489 100644 (file)
@@ -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;
index 5b0b361b4ffeacecbdfc4cc3640032f516e9c86f..abe7e624855be4a59a6bf8f0fb43be9e226ae85e 100644 (file)
@@ -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);
index af108a99984fa2a53f794791d7a3b33a89676618..c47bd464adafcb15adc561c66b9cc0ae7f8ae8dd 100644 (file)
@@ -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) {