]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: share quorum features on election victory
authorSage Weil <sage@inktank.com>
Thu, 13 Sep 2012 00:19:01 +0000 (17:19 -0700)
committerSage Weil <sage@inktank.com>
Thu, 13 Sep 2012 00:33:01 +0000 (17:33 -0700)
Inform peons what the quorum features are.  Previously only the leader
knew, which was of limited utility.

This is one piece of #2690.

Signed-off-by: Sage Weil <sage@inktank.com>
src/messages/MMonElection.h
src/mon/Elector.cc
src/mon/Monitor.cc
src/mon/Monitor.h

index 2f44c4ee8dc6d497f2699eae7c6e593b8fa2fd5c..b589d9842f1c16be6b01082d8a1d1abf4dd84327 100644 (file)
@@ -21,7 +21,8 @@
 
 class MMonElection : public Message {
 
-  static const int HEAD_VERSION = 2;
+  static const int HEAD_VERSION = 3;
+  static const int COMPAT_VERSION = 2;
 
 public:
   static const int OP_PROPOSE = 1;
@@ -43,12 +44,12 @@ public:
   epoch_t epoch;
   bufferlist monmap_bl;
   set<int> quorum;
+  uint64_t quorum_features;
   
-  MMonElection() : Message(MSG_MON_ELECTION, HEAD_VERSION) { }
-  MMonElection(int o, epoch_t e, MonMap *m) : 
-    Message(MSG_MON_ELECTION, HEAD_VERSION), 
-    fsid(m->fsid), op(o), epoch(e) {
-
+  MMonElection() : Message(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION) { }
+  MMonElection(int o, epoch_t e, MonMap *m)
+    : Message(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION),
+      fsid(m->fsid), op(o), epoch(e), quorum_features(0) {
     // encode using full feature set; we will reencode for dest later,
     // if necessary
     m->encode(monmap_bl, CEPH_FEATURES_ALL);
@@ -76,6 +77,7 @@ public:
     ::encode(epoch, payload);
     ::encode(monmap_bl, payload);
     ::encode(quorum, payload);
+    ::encode(quorum_features, payload);
   }
   void decode_payload() {
     bufferlist::iterator p = payload.begin();
@@ -87,6 +89,10 @@ public:
     ::decode(epoch, p);
     ::decode(monmap_bl, p);
     ::decode(quorum, p);
+    if (header.version >= 3)
+      ::decode(quorum_features, p);
+    else
+      quorum_features = 0;
   }
   
 };
index 515e21a5afa3147f294f70de8042837ddabd9dac..26190ee2aeb15ad0b83ce847448ecf9ff5c05ef8 100644 (file)
@@ -262,7 +262,7 @@ void Elector::handle_ack(MMonElection *m)
 
 void Elector::handle_victory(MMonElection *m)
 {
-  dout(5) << "handle_victory from " << m->get_source() << dendl;
+  dout(5) << "handle_victory from " << m->get_source() << " quorum_features " << m->quorum_features << dendl;
   int from = m->get_source().num();
 
   assert(from < mon->rank);
@@ -280,7 +280,7 @@ void Elector::handle_victory(MMonElection *m)
   bump_epoch(m->epoch);
   
   // they win
-  mon->lose_election(epoch, m->quorum, from);
+  mon->lose_election(epoch, m->quorum, from, m->quorum_features);
   
   // cancel my timer
   cancel_timer();      
index 287ff285e51d1afc1c9d8e3d2d3927cd81f64386..444e56004357919b759a010054bc699f72279d3b 100644 (file)
@@ -1083,7 +1083,7 @@ epoch_t Monitor::get_epoch()
   return elector.get_epoch();
 }
 
-void Monitor::win_election(epoch_t epoch, set<int>& active, unsigned features) 
+void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features) 
 {
   if (!is_electing())
     reset();
@@ -1109,16 +1109,16 @@ void Monitor::win_election(epoch_t epoch, set<int>& active, unsigned features)
   finish_election();
 }
 
-void Monitor::lose_election(epoch_t epoch, set<int> &q, int l) 
+void Monitor::lose_election(epoch_t epoch, set<int> &q, int l, uint64_t features
 {
   state = STATE_PEON;
   leader_since = utime_t();
   leader = l;
   quorum = q;
   outside_quorum.clear();
-  quorum_features = 0;
+  quorum_features = features;
   dout(10) << "lose_election, epoch " << epoch << " leader is mon" << leader
-          << " quorum is " << quorum << dendl;
+          << " quorum is " << quorum << " features are " << quorum_features << dendl;
 
   for (vector<Paxos*>::iterator p = paxos.begin(); p != paxos.end(); p++)
     (*p)->peon_init();
index f5cc1f636d1b93f994889f8765d1464330261898..fd45432f04fab7f856559254d16c1fb9044bcfb8 100644 (file)
@@ -236,8 +236,9 @@ public:
   void start_election();
   void win_standalone_election();
   void win_election(epoch_t epoch, set<int>& q,
-                   unsigned features);         // end election (called by Elector)
-  void lose_election(epoch_t epoch, set<int>& q, int l); // end election (called by Elector)
+                   uint64_t features);         // end election (called by Elector)
+  void lose_election(epoch_t epoch, set<int>& q, int l,
+                    uint64_t features); // end election (called by Elector)
   void finish_election();
 
   void update_logger();