summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-06-02 16:14:01 -0700
committerSage Weil <sage@inktank.com>2013-06-17 14:24:43 -0700
commitb3df87269f878da47709124d2e5040c8ac10addc (patch)
tree016457930dad5e9d2308e982bbcbc4383c35d353
parent5cf5f18e3d5521007d57c406fdd13ca626926f1c (diff)
downloadceph-b3df87269f878da47709124d2e5040c8ac10addc.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>
-rw-r--r--src/mon/Monitor.cc22
-rw-r--r--src/mon/Monitor.h1
-rw-r--r--src/mon/Paxos.cc8
-rw-r--r--src/mon/PaxosService.cc12
-rw-r--r--src/mon/PaxosService.h2
5 files changed, 27 insertions, 18 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 986d8633cc3..c70eaae31bb 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -521,11 +521,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) {
@@ -535,6 +532,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) {
@@ -3366,13 +3371,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 9e94fa90aaa..61e109771ec 100644
--- a/src/mon/Monitor.h
+++ b/src/mon/Monitor.h
@@ -1413,6 +1413,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 70f06870ec2..54579393c4d 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 79ea0d41281..71c1ea52790 100644
--- a/src/mon/PaxosService.cc
+++ b/src/mon/PaxosService.cc
@@ -68,9 +68,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!
@@ -111,6 +108,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;
@@ -257,7 +261,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 a49e60a6fdc..31f5ee89619 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.