From f28287f00d06fa55fc824cbef05904235cea32b9 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 6 Feb 2012 15:31:20 -0800 Subject: [PATCH] mon: make PaxosService::update_from_paxos return void. You can't really recover from a failed update (as PGMonitor was trying to do), and nothing in the system checks the return values. So rip out the return values and change failed updates to an assert failure (most of the other Monitors continue to have decode exceptions, but we can keep the pretty that we have). Signed-off-by: Greg Farnum --- src/mon/AuthMonitor.cc | 6 ++---- src/mon/AuthMonitor.h | 2 +- src/mon/LogMonitor.cc | 6 ++---- src/mon/LogMonitor.h | 2 +- src/mon/MDSMonitor.cc | 6 ++---- src/mon/MDSMonitor.h | 2 +- src/mon/MonmapMonitor.cc | 5 ++--- src/mon/MonmapMonitor.h | 2 +- src/mon/OSDMonitor.cc | 6 ++---- src/mon/OSDMonitor.h | 2 +- src/mon/PGMonitor.cc | 12 ++++++------ src/mon/PGMonitor.h | 2 +- src/mon/PaxosService.h | 2 +- 13 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 6cc002f8662c..29c5e7dab0b6 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -109,13 +109,13 @@ void AuthMonitor::create_initial() pending_auth.push_back(inc); } -bool AuthMonitor::update_from_paxos() +void AuthMonitor::update_from_paxos() { dout(10) << "update_from_paxos()" << dendl; version_t paxosv = paxos->get_version(); version_t keys_ver = mon->key_server.get_ver(); if (paxosv == keys_ver) - return true; + return; assert(paxosv >= keys_ver); if (keys_ver != paxos->get_stashed_version()) { @@ -190,8 +190,6 @@ bool AuthMonitor::update_from_paxos() if (mon->is_leader() && paxosv > max) paxos->trim_to(paxosv - max); - - return true; } void AuthMonitor::increase_max_global_id() diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 056484540b4a..c09abbe05cf5 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -94,7 +94,7 @@ private: void election_finished(); bool should_propose(double& delay); void create_initial(); - bool update_from_paxos(); + void update_from_paxos(); 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 2122aff36266..199054d27478 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -90,11 +90,11 @@ void LogMonitor::create_initial() pending_log.insert(pair(e.stamp, e)); } -bool LogMonitor::update_from_paxos() +void LogMonitor::update_from_paxos() { version_t paxosv = paxos->get_version(); if (paxosv == summary.version) - return true; + return; assert(paxosv >= summary.version); bufferlist blog; @@ -172,8 +172,6 @@ bool LogMonitor::update_from_paxos() unsigned max = g_conf->mon_max_log_epochs; if (mon->is_leader() && paxosv > max) paxos->trim_to(paxosv - max); - - return true; } void LogMonitor::create_pending() diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index da4c8d4cedad..38d11f132d61 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -34,7 +34,7 @@ private: LogSummary pending_summary, summary; void create_initial(); - bool update_from_paxos(); + void update_from_paxos(); void create_pending(); // prepare a new pending void encode_pending(bufferlist &bl); // propose pending update to peers diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index e704300e8541..96a69fca4511 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -80,11 +80,11 @@ void MDSMonitor::create_initial() } -bool MDSMonitor::update_from_paxos() +void MDSMonitor::update_from_paxos() { version_t paxosv = paxos->get_version(); if (paxosv == mdsmap.epoch) - return true; + return; assert(paxosv >= mdsmap.epoch); dout(10) << "update_from_paxos paxosv " << paxosv @@ -106,8 +106,6 @@ bool MDSMonitor::update_from_paxos() check_subs(); update_logger(); - - return true; } void MDSMonitor::create_pending() diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index 0b162375b9f9..cf869aef5eb0 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -67,7 +67,7 @@ class MDSMonitor : public PaxosService { // service methods void create_initial(); - bool update_from_paxos(); + void update_from_paxos(); void create_pending(); void encode_pending(bufferlist &bl); diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 4d30561e1da1..1ef58906c829 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -47,12 +47,12 @@ void MonmapMonitor::create_initial() pending_map.epoch = 1; } -bool MonmapMonitor::update_from_paxos() +void MonmapMonitor::update_from_paxos() { version_t paxosv = paxos->get_version(); if (paxosv <= paxos->get_stashed_version() && paxosv <= mon->monmap->get_epoch()) - return true; + return; dout(10) << "update_from_paxos paxosv " << paxosv << ", my v " << mon->monmap->epoch << dendl; @@ -86,7 +86,6 @@ bool MonmapMonitor::update_from_paxos() if (need_restart) mon->bootstrap(); - return true; } void MonmapMonitor::create_pending() diff --git a/src/mon/MonmapMonitor.h b/src/mon/MonmapMonitor.h index 0393de9dff0e..2f0d01fa5343 100644 --- a/src/mon/MonmapMonitor.h +++ b/src/mon/MonmapMonitor.h @@ -45,7 +45,7 @@ class MonmapMonitor : public PaxosService { void create_initial(); - bool update_from_paxos(); + void update_from_paxos(); void create_pending(); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e9e6a5fa592a..139d5f943b92 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -86,11 +86,11 @@ void OSDMonitor::create_initial() newmap.encode(pending_inc.fullmap); } -bool OSDMonitor::update_from_paxos() +void OSDMonitor::update_from_paxos() { version_t paxosv = paxos->get_version(); if (paxosv == osdmap.epoch) - return true; + return; assert(paxosv >= osdmap.epoch); dout(15) << "update_from_paxos paxos e " << paxosv @@ -146,8 +146,6 @@ bool OSDMonitor::update_from_paxos() share_map_with_random_osd(); update_logger(); - - return true; } void OSDMonitor::on_active() diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 5cf95fe107bf..f3b42b0b33ae 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -53,7 +53,7 @@ private: public: void create_initial(); private: - bool update_from_paxos(); + void update_from_paxos(); void create_pending(); // prepare a new pending void encode_pending(bufferlist &bl); void on_active(); diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 2af59255c0f2..c2b0566972f7 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -197,11 +197,11 @@ void PGMonitor::create_initial() dout(10) << "create_initial -- creating initial map" << dendl; } -bool PGMonitor::update_from_paxos() +void PGMonitor::update_from_paxos() { version_t paxosv = paxos->get_version(); if (paxosv == pg_map.version) - return true; + return; assert(paxosv >= pg_map.version); if (pg_map.version != paxos->get_stashed_version()) { @@ -217,7 +217,8 @@ bool PGMonitor::update_from_paxos() catch (const std::exception &e) { dout(0) << "update_from_paxos: error parsing update: " << e.what() << dendl; - return false; + assert(0 == "update_from_paxos: error parsing update"); + return; } } @@ -237,7 +238,8 @@ bool PGMonitor::update_from_paxos() catch (const std::exception &e) { dout(0) << "update_from_paxos: error parsing " << "incremental update: " << e.what() << dendl; - return false; + assert(0 == "update_from_paxos: error parsing incremental update"); + return; } pg_map.apply_incremental(inc); @@ -272,8 +274,6 @@ bool PGMonitor::update_from_paxos() send_pg_creates(); update_logger(); - - return true; } void PGMonitor::handle_osd_timeouts() diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 65204b36d501..42ba9c4dd882 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -53,7 +53,7 @@ private: PGMap::Incremental pending_inc; void create_initial(); - bool update_from_paxos(); + void update_from_paxos(); void handle_osd_timeouts(); void create_pending(); // prepare a new pending void encode_pending(bufferlist &bl); // propose pending update to peers diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index c8dc93bd7cf7..43e92823b7b0 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -96,7 +96,7 @@ public: * it's newer than the current Monitor state. * Return true on success. */ - virtual bool update_from_paxos() = 0; + virtual void update_from_paxos() = 0; /* * This function is only called on a leader. Create the pending state. -- 2.47.3