From: Joao Eduardo Luis Date: Thu, 15 Nov 2012 02:16:17 +0000 (+0000) Subject: mon: Paxos{,Service}: finish contexts and put messages on shutdown X-Git-Tag: v0.55~76^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbe2e1ad0221c7018f5bfdf63eba999ec2690633;p=ceph.git mon: Paxos{,Service}: finish contexts and put messages on shutdown Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 884cd6b1f740..49fecc6f2ee2 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -24,9 +24,9 @@ using namespace std; #include "PaxosService.h" #include "common/LogEntry.h" +#include "messages/MLog.h" class MMonCommand; -class MLog; class LogMonitor : public PaxosService { private: @@ -52,6 +52,11 @@ private: MLog *ack; C_Log(LogMonitor *p, MLog *a) : logmon(p), ack(a) {} void finish(int r) { + if (r == -ECANCELED) { + if (ack) + ack->put(); + return; + } logmon->_updated_log(ack); } }; diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index b11fbc88a6b2..d852785fa909 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -30,8 +30,8 @@ using namespace std; #include "PaxosService.h" #include "Session.h" +#include "messages/MMDSBeacon.h" -class MMDSBeacon; class MMDSGetMap; class MMonCommand; class MMDSLoadTargets; @@ -54,6 +54,11 @@ class MDSMonitor : public PaxosService { C_Updated(MDSMonitor *a, MMDSBeacon *c) : mm(a), m(c) {} void finish(int r) { + if (r == -ECANCELED) { + if (m) + m->put(); + return; + } if (r >= 0) mm->_updated(m); // success else diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 3ff7733b2968..a82f5f0faf44 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -31,11 +31,11 @@ using namespace std; #include "Session.h" class Monitor; -class MOSDBoot; -class MMonCommand; -class MPoolSnap; -class MOSDMap; -class MOSDFailure; +#include "messages/MOSDBoot.h" +#include "messages/MMonCommand.h" +#include "messages/MOSDMap.h" +#include "messages/MOSDFailure.h" +#include "messages/MPoolOp.h" /// information about a particular peer's failure reports for one osd struct failure_reporter_t { @@ -208,6 +208,12 @@ private: C_Booted(OSDMonitor *cm, MOSDBoot *m_, bool l=true) : cmon(cm), m(m_), logit(l) {} void finish(int r) { + if (r == -ECANCELED) { + if (m) + m->put(); + return; + } + if (r >= 0) cmon->_booted(m, logit); else @@ -221,6 +227,11 @@ private: epoch_t e; C_ReplyMap(OSDMonitor *o, PaxosServiceMessage *mm, epoch_t ee) : osdmon(o), m(mm), e(ee) {} void finish(int r) { + if (r == -ECANCELED) { + if (m) + m->put(); + return; + } osdmon->_reply_map(m, e); } }; @@ -233,6 +244,11 @@ private: C_PoolOp(OSDMonitor * osd, MPoolOp *m_, int rc, int e, bufferlist *rd=NULL) : osdmon(osd), m(m_), replyCode(rc), epoch(e), reply_data(rd) {} void finish(int r) { + if (r == -ECANCELED) { + if (m) + m->put(); + return; + } osdmon->_pool_op_reply(m, replyCode, epoch, reply_data); } }; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index f8d311235cea..2bdfbc4b5ebc 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -545,6 +545,8 @@ struct RetryCheckOSDMap : public Context { epoch_t epoch; RetryCheckOSDMap(PGMonitor *p, epoch_t e) : pgmon(p), epoch(e) {} void finish(int r) { + if (r == -ECANCELED) + return; pgmon->check_osd_map(epoch); } }; diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 732aa6764200..2927c00453a6 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -31,8 +31,8 @@ using namespace std; #include "msg/Messenger.h" #include "common/config.h" -class MPGStats; -class MPGStatsAck; +#include "messages/MPGStats.h" +#include "messages/MPGStatsAck.h" class MStatfs; class MMonCommand; class MGetPoolStats; @@ -71,6 +71,11 @@ private: entity_inst_t who; C_Stats(PGMonitor *p, MPGStats *r, MPGStatsAck *a) : pgmon(p), req(r), ack(a) {} void finish(int r) { + if (r == -ECANCELED) { + req->put(); + ack->put(); + return; + } pgmon->_updated_stats(req, ack); } }; diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 0be63574530d..349908789e38 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -842,6 +842,14 @@ void Paxos::cancel_events() } } +void Paxos::shutdown() { + dout(10) << __func__ << " cancel all contexts" << dendl; + finish_contexts(g_ceph_context, waiting_for_writeable, -ECANCELED); + finish_contexts(g_ceph_context, waiting_for_commit, -ECANCELED); + finish_contexts(g_ceph_context, waiting_for_readable, -ECANCELED); + finish_contexts(g_ceph_context, waiting_for_active, -ECANCELED); +} + void Paxos::leader_init() { cancel_events(); @@ -869,8 +877,8 @@ void Paxos::peon_init() dout(10) << "peon_init -- i am a peon" << dendl; // no chance to write now! - finish_contexts(g_ceph_context, waiting_for_writeable, -1); - finish_contexts(g_ceph_context, waiting_for_commit, -1); + finish_contexts(g_ceph_context, waiting_for_writeable, -EAGAIN); + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); } void Paxos::restart() @@ -879,8 +887,8 @@ void Paxos::restart() cancel_events(); new_value.clear(); - finish_contexts(g_ceph_context, waiting_for_commit, -1); - finish_contexts(g_ceph_context, waiting_for_active, -1); + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); + finish_contexts(g_ceph_context, waiting_for_active, -EAGAIN); } diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index d0481884ee7c..adc8af399adf 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -47,6 +47,7 @@ e 12v #include "include/Context.h" #include "common/Timer.h" +#include class Monitor; class MMonPaxos; @@ -450,6 +451,8 @@ private: public: C_CollectTimeout(Paxos *p) : paxos(p) {} void finish(int r) { + if (r == -ECANCELED) + return; paxos->collect_timeout(); } }; @@ -462,6 +465,8 @@ private: public: C_AcceptTimeout(Paxos *p) : paxos(p) {} void finish(int r) { + if (r == -ECANCELED) + return; paxos->accept_timeout(); } }; @@ -474,6 +479,8 @@ private: public: C_LeaseAckTimeout(Paxos *p) : paxos(p) {} void finish(int r) { + if (r == -ECANCELED) + return; paxos->lease_ack_timeout(); } }; @@ -486,6 +493,8 @@ private: public: C_LeaseTimeout(Paxos *p) : paxos(p) {} void finish(int r) { + if (r == -ECANCELED) + return; paxos->lease_timeout(); } }; @@ -498,6 +507,8 @@ private: public: C_LeaseRenew(Paxos *p) : paxos(p) {} void finish(int r) { + if (r == -ECANCELED) + return; paxos->lease_renew_timeout(); } }; @@ -811,6 +822,10 @@ private: * Cancel all of Paxos' timeout/renew events. */ void cancel_events(); + /** + * Shutdown this Paxos machine + */ + void shutdown(); /** * Generate a new Proposal Number based on @p gt diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 167781bc766e..db52667378cd 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -199,6 +199,7 @@ void PaxosService::_active() void PaxosService::shutdown() { paxos->cancel_events(); + paxos->shutdown(); if (proposal_timer) { mon->timer.cancel_event(proposal_timer); diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 2cb59a3d61a2..78bcc8d367de 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -17,6 +17,7 @@ #include "messages/PaxosServiceMessage.h" #include "include/Context.h" +#include class Monitor; class Paxos; @@ -63,6 +64,10 @@ protected: public: C_RetryMessage(PaxosService *s, PaxosServiceMessage *m_) : svc(s), m(m_) {} void finish(int r) { + if (r == -ECANCELED) { + m->put(); + return; + } svc->dispatch(m); } }; @@ -93,7 +98,9 @@ protected: PaxosService *ps; public: C_Propose(PaxosService *p) : ps(p) { } - void finish(int r) { + void finish(int r) { + if (r == -ECANCELED) + return; ps->proposal_timer = 0; ps->propose_pending(); }