]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Paxos{,Service}: finish contexts and put messages on shutdown
authorJoao Eduardo Luis <joao.luis@inktank.com>
Thu, 15 Nov 2012 02:16:17 +0000 (02:16 +0000)
committerSage Weil <sage@inktank.com>
Sun, 18 Nov 2012 16:28:59 +0000 (08:28 -0800)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/LogMonitor.h
src/mon/MDSMonitor.h
src/mon/OSDMonitor.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/Paxos.cc
src/mon/Paxos.h
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 884cd6b1f74026afb5f667f6bfe0b4ec5a5e13f9..49fecc6f2ee2ad5a6898c4ea21469bf75b5fe9ed 100644 (file)
@@ -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);
     }    
   };
index b11fbc88a6b25ef789bd64cf56e257022e65f0ea..d852785fa909ff905a6d30a6ebf0ff51874e125f 100644 (file)
@@ -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
index 3ff7733b29682435729735f6480482a86029e580..a82f5f0faf44634432f0c9a46640808ad39c0c4b 100644 (file)
@@ -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);
     }
   };
index f8d311235ceae3fb4ac6e9985c0bd4935c393a9b..2bdfbc4b5ebc8130404a527726a28ef55071ccaa 100644 (file)
@@ -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);
   }
 };
index 732aa6764200bc0e976ef673bc54f284b87d1b24..2927c00453a6f8cb4d2bd8ca5a7ec1a8fd27ecd7 100644 (file)
@@ -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);
     }    
   };
index 0be63574530d6b4b5ba0e9411d876189e1b3b477..349908789e387d5d1b7cc1587757562ea55a79e7 100644 (file)
@@ -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);
 }
 
 
index d0481884ee7ce763fa5d6f38b3abfebbcccc635f..adc8af399adf54a0c6b1eb6c5dfa6608353e1fd2 100644 (file)
@@ -47,6 +47,7 @@ e 12v
 #include "include/Context.h"
 
 #include "common/Timer.h"
+#include <errno.h>
 
 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
index 167781bc766ea21c7b2c443240e21e3b1475994b..db52667378cd284a2acd7a4957b2910ea6a00861 100644 (file)
@@ -199,6 +199,7 @@ void PaxosService::_active()
 void PaxosService::shutdown()
 {
   paxos->cancel_events();
+  paxos->shutdown();
 
   if (proposal_timer) {
     mon->timer.cancel_event(proposal_timer);
index 2cb59a3d61a2848e2f1ed80366a241f97006ddaf..78bcc8d367de6017e8d1fdd51905ebb2bc3b5ea3 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "messages/PaxosServiceMessage.h"
 #include "include/Context.h"
+#include <errno.h>
 
 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(); 
     }