From 4072ef782e474a03e888f52ad4cc1f1eb2653f50 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 30 Sep 2014 17:15:25 -0700 Subject: [PATCH] mon: move paxos write wait into a helper Avoid duplicated code. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 84c66466e08bd..8f0b67a96b72b 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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); -- 2.39.5