]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: cleanup uncommitted fragments before mds goes to active 35448/head
authorYan, Zheng <zyan@redhat.com>
Mon, 25 May 2020 13:48:23 +0000 (21:48 +0800)
committerNathan Cutler <ncutler@suse.com>
Sat, 6 Jun 2020 08:55:20 +0000 (10: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 630f7ce0d5b5df91288b221cb33f15e1490209c3..325cbfc88ecef8e58bd869805537dbaa38b61607 100644 (file)
@@ -12209,6 +12209,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 d6d4d11c9e923cba315839ff60e0f09d840c1659..bb6759617a5a040fc74023ecede0547a17792780 100644 (file)
@@ -872,12 +872,16 @@ class MDCache {
   void send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequestRef& mdr);
 
   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 6c18068893d36138df16c657ece919811fec7123..93f687f25ede943b7a6f7fbdc0895090c1a215c4 100644 (file)
@@ -1890,6 +1890,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) {