diff options
author | Sage Weil <sage@inktank.com> | 2013-06-02 16:14:01 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-06-24 16:16:40 -0700 |
commit | 34acc5a3161b6bcda2b9f7ce18d89a8618fff1c5 (patch) | |
tree | 22be99da8e673e83af4445f0d5165f2d9d6cfca3 | |
parent | 4474a0cc6c009a566ecf46efadb39d80343a7c68 (diff) | |
download | ceph-34acc5a3161b6bcda2b9f7ce18d89a8618fff1c5.tar.gz |
mon: explicitly refresh_from_paxos() when leveldb state changes
Instead of opportunistically calling each service's update_from_paxos(),
instead explicitly refresh all in-memory state whenever we know the
paxos state may have changed. This is simpler and less fragile.
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit cc339c07312006e65854207523f50542d00ecf87)
-rw-r--r-- | src/mon/Monitor.cc | 22 | ||||
-rw-r--r-- | src/mon/Monitor.h | 1 | ||||
-rw-r--r-- | src/mon/Paxos.cc | 8 | ||||
-rw-r--r-- | src/mon/PaxosService.cc | 12 | ||||
-rw-r--r-- | src/mon/PaxosService.h | 2 |
5 files changed, 27 insertions, 18 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 65577b699ae..522434997d1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -515,11 +515,8 @@ void Monitor::init_paxos() paxos->init(); // update paxos - for (int i = 0; i < PAXOS_NUM; ++i) { - if (paxos->is_consistent()) { - paxos_service[i]->update_from_paxos(); - } - } + if (paxos->is_consistent()) + refresh_from_paxos(); // init services for (int i = 0; i < PAXOS_NUM; ++i) { @@ -529,6 +526,14 @@ void Monitor::init_paxos() } } +void Monitor::refresh_from_paxos() +{ + dout(10) << __func__ << dendl; + for (int i = 0; i < PAXOS_NUM; ++i) { + paxos_service[i]->refresh(); + } +} + void Monitor::register_cluster_logger() { if (!cluster_logger_registered) { @@ -3336,13 +3341,6 @@ bool Monitor::_ms_dispatch(Message *m) } paxos->dispatch((PaxosServiceMessage*)m); - - // make sure service finds out about any state changes - if (paxos->is_active()) { - vector<PaxosService*>::iterator service_it = paxos_service.begin(); - for ( ; service_it != paxos_service.end(); ++service_it) - (*service_it)->update_from_paxos(); - } } break; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 74a94be4e0a..cea2a23d978 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -1412,6 +1412,7 @@ public: int preinit(); int init(); void init_paxos(); + void refresh_from_paxos(); void shutdown(); void tick(); diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index f5cbe89092b..6adf191ee91 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -509,12 +509,12 @@ void Paxos::begin(bufferlist& v) // we're alone, take it easy commit(); state = STATE_ACTIVE; + mon->refresh_from_paxos(); finish_proposal(); finish_contexts(g_ceph_context, waiting_for_active); finish_contexts(g_ceph_context, waiting_for_commit); finish_contexts(g_ceph_context, waiting_for_readable); finish_contexts(g_ceph_context, waiting_for_writeable); - return; } @@ -627,6 +627,8 @@ void Paxos::handle_accept(MMonPaxos *accept) // yay! state = STATE_ACTIVE; extend_lease(); + + mon->refresh_from_paxos(); finish_proposal(); @@ -713,9 +715,11 @@ void Paxos::handle_commit(MMonPaxos *commit) } store_state(commit); - + commit->put(); + mon->refresh_from_paxos(); + finish_contexts(g_ceph_context, waiting_for_commit); } diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 0421078b0d5..cb808036b2e 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -63,9 +63,6 @@ bool PaxosService::dispatch(PaxosServiceMessage *m) return true; } - // make sure service has latest from paxos. - update_from_paxos(); - // preprocess if (preprocess_query(m)) return true; // easy! @@ -106,6 +103,13 @@ bool PaxosService::dispatch(PaxosServiceMessage *m) return true; } +void PaxosService::refresh() +{ + dout(10) << __func__ << dendl; + update_from_paxos(); +} + + void PaxosService::scrub() { dout(10) << __func__ << dendl; @@ -252,7 +256,7 @@ void PaxosService::_active() dout(10) << "_active" << dendl; // pull latest from paxos - update_from_paxos(); + refresh(); scrub(); diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 4de73ea4b19..158eda7def8 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -313,6 +313,8 @@ public: */ bool dispatch(PaxosServiceMessage *m); + void refresh(); + /** * @defgroup PaxosService_h_override_funcs Functions that should be * overridden. |