]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move paxos write wait into a helper
authorSage Weil <sage@redhat.com>
Wed, 1 Oct 2014 00:15:25 +0000 (17:15 -0700)
committerSage Weil <sage@redhat.com>
Wed, 1 Oct 2014 00:15:25 +0000 (17:15 -0700)
Avoid duplicated code.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/Monitor.cc

index 84c66466e08bdfc6f470d47b81700739c9654fa0..8f0b67a96b72bd31ff552f8f659de49acef2d279 100644 (file)
@@ -865,14 +865,7 @@ void Monitor::shutdown()
   lock.Lock();
 
   state = STATE_SHUTDOWN;
-
-  if (paxos->is_writing() || paxos->is_writing_previous()) {
-    dout(10) << __func__ << " flushing" << dendl;
-    lock.Unlock();
-    store->flush();
-    lock.Lock();
-    dout(10) << __func__ << " flushed" << dendl;
-  }
+  wait_for_paxos_write();
 
   if (admin_hook) {
     AdminSocket* admin_socket = cct->get_admin_socket();
@@ -919,15 +912,21 @@ void Monitor::shutdown()
   messenger->shutdown();  // last thing!  ceph_mon.cc will delete mon.
 }
 
-void Monitor::bootstrap()
+void Monitor::wait_for_paxos_write()
 {
   if (paxos->is_writing() || paxos->is_writing_previous()) {
-    dout(10) << "bootstrap flushing pending write" << dendl;
+    dout(10) << __func__ << " flushing pending write" << dendl;
     lock.Unlock();
     store->flush();
     lock.Lock();
+    dout(10) << __func__ << " flushed pending write" << dendl;
   }
+}
+
+void Monitor::bootstrap()
+{
   dout(10) << "bootstrap" << dendl;
+  wait_for_paxos_write();
 
   sync_reset_requester();
   unregister_cluster_logger();
@@ -2553,11 +2552,7 @@ void Monitor::handle_command(MMonCommand *m)
   }
 
   if (prefix == "scrub") {
-    while (paxos->is_writing() || paxos->is_writing_previous()) {
-      lock.Unlock();
-      store->flush();
-      lock.Lock();
-    }
+    wait_for_paxos_write();
     if (is_leader()) {
       int r = scrub();
       reply_command(m, r, "", rdata, 0);