diff options
author | Sage Weil <sage@inktank.com> | 2013-05-31 15:32:06 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-06-17 14:24:44 -0700 |
commit | 19bcd389bb4fa36838565d8c5ea6b03984ed0709 (patch) | |
tree | 03ca808a40ed0dd895314cd4f2b2b8bbda243532 | |
parent | 230578429183a0e812dd953a7ecb9d1aabb6cfd0 (diff) | |
download | ceph-19bcd389bb4fa36838565d8c5ea6b03984ed0709.tar.gz |
mon: safely signal bootstrap from MonmapMonitor::update_from_paxos()
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/mon/AuthMonitor.cc | 2 | ||||
-rw-r--r-- | src/mon/AuthMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/LogMonitor.cc | 2 | ||||
-rw-r--r-- | src/mon/LogMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/MDSMonitor.cc | 2 | ||||
-rw-r--r-- | src/mon/MDSMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/Monitor.cc | 6 | ||||
-rw-r--r-- | src/mon/Monitor.h | 2 | ||||
-rw-r--r-- | src/mon/MonmapMonitor.cc | 11 | ||||
-rw-r--r-- | src/mon/MonmapMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 2 | ||||
-rw-r--r-- | src/mon/OSDMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/PGMonitor.cc | 2 | ||||
-rw-r--r-- | src/mon/PGMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/Paxos.cc | 11 | ||||
-rw-r--r-- | src/mon/PaxosService.cc | 4 | ||||
-rw-r--r-- | src/mon/PaxosService.h | 4 |
17 files changed, 33 insertions, 27 deletions
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 4b046268bea..80ac8435ebf 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -111,7 +111,7 @@ void AuthMonitor::create_initial() pending_auth.push_back(inc); } -void AuthMonitor::update_from_paxos() +void AuthMonitor::update_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; version_t version = get_version(); diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 9368fcd8613..5c17105692b 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -130,7 +130,7 @@ private: void on_active(); bool should_propose(double& delay); void create_initial(); - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void create_pending(); // prepare a new pending bool prepare_global_id(MMonGlobalID *m); void increase_max_global_id(); diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index ec4656d4ec4..54aea67eb8f 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -90,7 +90,7 @@ void LogMonitor::create_initial() pending_log.insert(pair<utime_t,LogEntry>(e.stamp, e)); } -void LogMonitor::update_from_paxos() +void LogMonitor::update_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; version_t version = get_version(); diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 9eee758d47f..e20c81e227b 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -34,7 +34,7 @@ private: LogSummary pending_summary, summary; void create_initial(); - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void create_pending(); // prepare a new pending // propose pending update to peers void encode_pending(MonitorDBStore::Transaction *t); diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index b5066c77cee..5f4582fdce3 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -84,7 +84,7 @@ void MDSMonitor::create_initial() } -void MDSMonitor::update_from_paxos() +void MDSMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_version(); if (version == mdsmap.epoch) diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index 52841cfff10..b6ca84022af 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -68,7 +68,7 @@ class MDSMonitor : public PaxosService { // service methods void create_initial(); - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void create_pending(); void encode_pending(MonitorDBStore::Transaction *t); // we don't require full versions; don't encode any. diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c70eaae31bb..6eab53a5a57 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -522,7 +522,7 @@ void Monitor::init_paxos() // update paxos if (paxos->is_consistent()) - refresh_from_paxos(); + refresh_from_paxos(NULL); // init services for (int i = 0; i < PAXOS_NUM; ++i) { @@ -532,11 +532,11 @@ void Monitor::init_paxos() } } -void Monitor::refresh_from_paxos() +void Monitor::refresh_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; for (int i = 0; i < PAXOS_NUM; ++i) { - paxos_service[i]->refresh(); + paxos_service[i]->refresh(need_bootstrap); } } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 61e109771ec..dfbe8a081dd 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -1413,7 +1413,7 @@ public: int preinit(); int init(); void init_paxos(); - void refresh_from_paxos(); + void refresh_from_paxos(bool *need_bootstrap); void shutdown(); void tick(); diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 435ac77cd05..cfc7bf7f297 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -47,7 +47,7 @@ void MonmapMonitor::create_initial() pending_map.epoch = 1; } -void MonmapMonitor::update_from_paxos() +void MonmapMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_version(); if (version <= mon->monmap->get_epoch()) @@ -95,7 +95,10 @@ void MonmapMonitor::update_from_paxos() mon->monmap->decode(latest_bl); } */ - bool need_restart = version != mon->monmap->get_epoch(); + if (need_bootstrap && version != mon->monmap->get_epoch()) { + dout(10) << " signaling that we need a bootstrap" << dendl; + *need_bootstrap = true; + } // read and decode monmap_bl.clear(); @@ -111,10 +114,6 @@ void MonmapMonitor::update_from_paxos() erase_mkfs(&t); mon->store->apply_transaction(t); } - - if (need_restart) { - mon->bootstrap(); - } } void MonmapMonitor::create_pending() diff --git a/src/mon/MonmapMonitor.h b/src/mon/MonmapMonitor.h index 0690fb7409f..198489d7017 100644 --- a/src/mon/MonmapMonitor.h +++ b/src/mon/MonmapMonitor.h @@ -46,7 +46,7 @@ class MonmapMonitor : public PaxosService { void create_initial(); - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void create_pending(); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 04124f772a5..f1728c0240d 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -105,7 +105,7 @@ void OSDMonitor::create_initial() newmap.encode(pending_inc.fullmap); } -void OSDMonitor::update_from_paxos() +void OSDMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_version(); if (version == osdmap.epoch) diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index ef5ba77462b..ab0962c0a6b 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -145,7 +145,7 @@ private: public: void create_initial(); private: - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void create_pending(); // prepare a new pending void encode_pending(MonitorDBStore::Transaction *t); virtual void encode_full(MonitorDBStore::Transaction *t); diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index a8923662934..a9f3c1b6c5d 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -149,7 +149,7 @@ void PGMonitor::create_initial() dout(10) << "create_initial -- creating initial map" << dendl; } -void PGMonitor::update_from_paxos() +void PGMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_version(); if (version == pg_map.version) diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index e3afd0df247..b18b76b1288 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -51,7 +51,7 @@ private: PGMap::Incremental pending_inc; void create_initial(); - void update_from_paxos(); + void update_from_paxos(bool *need_bootstrap); void init(); void handle_osd_timeouts(); void create_pending(); // prepare a new pending diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 9c6d11345e8..0d6d96de2e3 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -715,7 +715,7 @@ void Paxos::handle_commit(MMonPaxos *commit) commit->put(); - mon->refresh_from_paxos(); + mon->refresh_from_paxos(NULL); finish_contexts(g_ceph_context, waiting_for_commit); } @@ -786,7 +786,8 @@ void Paxos::finish_proposal() assert(mon->is_leader()); // make sure we have the latest state loaded up - mon->refresh_from_paxos(); + bool need_bootstrap = false; + mon->refresh_from_paxos(&need_bootstrap); // finish off the last proposal if (!proposals.empty()) { @@ -821,6 +822,12 @@ void Paxos::finish_proposal() first_committed = get_store()->get(get_name(), "first_committed"); last_committed = get_store()->get(get_name(), "last_committed"); + if (need_bootstrap) { + dout(10) << " doing requested bootstrap" << dendl; + mon->bootstrap(); + return; + } + if (should_trim()) { trim(); } diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 30b3b6e767c..b2a734a9b6c 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -109,7 +109,7 @@ bool PaxosService::dispatch(PaxosServiceMessage *m) return true; } -void PaxosService::refresh() +void PaxosService::refresh(bool *need_bootstrap) { // update cached versions cached_first_committed = mon->store->get(get_service_name(), first_committed_name); @@ -117,7 +117,7 @@ void PaxosService::refresh() dout(10) << __func__ << dendl; - update_from_paxos(); + update_from_paxos(need_bootstrap); } diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index ce232e559d3..4b0cb38b1ad 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -314,7 +314,7 @@ public: */ bool dispatch(PaxosServiceMessage *m); - void refresh(); + void refresh(bool *need_bootstrap); /** * @defgroup PaxosService_h_override_funcs Functions that should be @@ -338,7 +338,7 @@ public: * * @returns 'true' on success; 'false' otherwise. */ - virtual void update_from_paxos() = 0; + virtual void update_from_paxos(bool *need_bootstrap) = 0; /** * Init on startup |