]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: ESessions now uses modern encoding
authorGreg Farnum <greg@inktank.com>
Fri, 25 Jan 2013 01:54:21 +0000 (17:54 -0800)
committerGreg Farnum <greg@inktank.com>
Fri, 8 Feb 2013 21:17:53 +0000 (13:17 -0800)
To facilitate this (since it had no versioning previously), it
gets a new encoding number and LogEvent::decode() sets a switch
if it's the old encoding.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/LogEvent.cc
src/mds/LogEvent.h
src/mds/events/ESessions.h
src/mds/journal.cc

index cee838820efeb4be2358ecc9421e824dd35b71c6..777c0a6ce6fea6019ea52a3d7bb2757dcc84c193 100644 (file)
@@ -63,6 +63,7 @@ LogEvent *LogEvent::decode(bufferlist& bl)
   case EVENT_RESETJOURNAL: le = new EResetJournal; break;
 
   case EVENT_SESSION: le = new ESession; break;
+  case EVENT_SESSIONS_OLD: le = new ESessions; ((ESessions *)le)->mark_old_encoding(); break;
   case EVENT_SESSIONS: le = new ESessions; break;
 
   case EVENT_UPDATE: le = new EUpdate; break;
index 9ff5cb85f63f7ae10566caa752fd3856c29d0d49..98d95d4314c8b8bcc0a72fecf40b7e43ec3e595a 100644 (file)
@@ -26,7 +26,8 @@
 #define EVENT_RESETJOURNAL 9
 
 #define EVENT_SESSION      10
-#define EVENT_SESSIONS     11
+#define EVENT_SESSIONS_OLD 11
+#define EVENT_SESSIONS     12
 
 #define EVENT_UPDATE       20
 #define EVENT_SLAVEUPDATE  21
index 9b090cee394ace1ba72039356086150861ca73d8..ebc5edaec92b0107914480f0283199c5d854ffd3 100644 (file)
@@ -26,25 +26,43 @@ protected:
 
 public:
   map<client_t,entity_inst_t> client_map;
+  bool old_style_encode;
 
-  ESessions() : LogEvent(EVENT_SESSIONS) { }
+  ESessions() : LogEvent(EVENT_SESSIONS), old_style_encode(false) { }
   ESessions(version_t pv, map<client_t,entity_inst_t>& cm) :
     LogEvent(EVENT_SESSIONS),
-    cmapv(pv) {
+    cmapv(pv),
+    old_style_encode(false) {
     client_map.swap(cm);
   }
+
+  void mark_old_encoding() { old_style_encode = true; }
   
   void encode(bufferlist &bl) const {
+    ENCODE_START(1, 1, bl);
     ::encode(client_map, bl);
     ::encode(cmapv, bl);
     ::encode(stamp, bl);
+    ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::iterator &bl) {
+  void decode_old(bufferlist::iterator &bl) {
     ::decode(client_map, bl);
     ::decode(cmapv, bl);
     if (!bl.end())
       ::decode(stamp, bl);
   }
+  void decode_new(bufferlist::iterator &bl) {
+    DECODE_START(1, bl);
+    ::decode(client_map, bl);
+    ::decode(cmapv, bl);
+    if (!bl.end())
+      ::decode(stamp, bl);
+    DECODE_FINISH(bl);
+  }
+  void decode(bufferlist::iterator &bl) {
+    if (old_style_encode) decode_old(bl);
+    else decode_new(bl);
+  }
 
 
   void print(ostream& out) {
index 4a7c750b641d401c935a9c7e84e76e65cc9d65f1..3968eee7dac5864b5a10b75f8839523c4b6b8d46 100644 (file)
@@ -1414,7 +1414,7 @@ void ESession::generate_test_instances(list<ESession*>& ls)
 }
 
 // -----------------------
-// ESession
+// ESessions
 
 void ESessions::update_segment()
 {