]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Clean up finished two phase commits
authorYan, Zheng <zheng.z.yan@intel.com>
Wed, 19 Sep 2012 07:52:36 +0000 (15:52 +0800)
committerSage Weil <sage@inktank.com>
Thu, 20 Sep 2012 18:09:40 +0000 (11:09 -0700)
When handling master request with slaves, the mds could crash
after receiving all slaves' commit acknowledgement, but before
journalling the ECommitted. Current MDS recovery code does not
handle this case correctly, the request will be left in
LogSegment's uncommitted_masters after recovery is finished.
It prevents LogSegment from being trimmed. The fix is find and
clean up request of this kind when recovery enters rejoin stage.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Sage Weil <sage@inktank.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc

index 9ac7a62facbf913f78113611d6ab152388cf1c31..da3affbe1a1d9e64e2bd4c6b532190188acfcde2 100644 (file)
@@ -2163,6 +2163,24 @@ void MDCache::committed_master_slave(metareqid_t r, int from)
 }
 
 
+/*
+ * The mds could crash after receiving all slaves' commit acknowledgement,
+ * but before journalling the ECommitted.
+ */
+void MDCache::finish_committed_masters()
+{
+  map<metareqid_t, umaster>::iterator p = uncommitted_masters.begin();
+  while (p != uncommitted_masters.end()) {
+    if (p->second.slaves.empty()) {
+      metareqid_t reqid = p->first;
+      dout(10) << "finish_committed_masters " << reqid << dendl;
+      ++p;
+      log_master_commit(reqid);
+    } else {
+      ++p;
+    }
+  }
+}
 
 /*
  * at end of resolve... we must journal a commit|abort for all slave
index 9c7b096fe52104a3261ce42155a914aaccfa39ca..12bdb0300a8067c17de31f34f58d637cfbeb6a6a 100644 (file)
@@ -291,6 +291,7 @@ public:
   void log_master_commit(metareqid_t reqid);
   void _logged_master_commit(metareqid_t reqid, LogSegment *ls, list<Context*> &waiters);
   void committed_master_slave(metareqid_t r, int from);
+  void finish_committed_masters();
 
   void _logged_slave_commit(int from, metareqid_t reqid);
 
index ce306c466db7b4f0ec05c9033d67c8893a13dfe5..d0aac301d8703c9707c4d01b6315ead10c0bf258 100644 (file)
@@ -1413,6 +1413,7 @@ void MDS::reconnect_done()
 void MDS::rejoin_joint_start()
 {
   dout(1) << "rejoin_joint_start" << dendl;
+  mdcache->finish_committed_masters();
   mdcache->rejoin_send_rejoins();
 }
 void MDS::rejoin_done()