From: Greg Farnum Date: Fri, 25 Jan 2013 01:54:21 +0000 (-0800) Subject: mds: ESessions now uses modern encoding X-Git-Tag: v0.58~100^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8e8ecb47a7cbd3e58da2e6e8260eeab55c1c907d;p=ceph.git mds: ESessions now uses modern encoding 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 --- diff --git a/src/mds/LogEvent.cc b/src/mds/LogEvent.cc index cee838820efe..777c0a6ce6fe 100644 --- a/src/mds/LogEvent.cc +++ b/src/mds/LogEvent.cc @@ -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; diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h index 9ff5cb85f63f..98d95d4314c8 100644 --- a/src/mds/LogEvent.h +++ b/src/mds/LogEvent.h @@ -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 diff --git a/src/mds/events/ESessions.h b/src/mds/events/ESessions.h index 9b090cee394a..ebc5edaec92b 100644 --- a/src/mds/events/ESessions.h +++ b/src/mds/events/ESessions.h @@ -26,25 +26,43 @@ protected: public: map client_map; + bool old_style_encode; - ESessions() : LogEvent(EVENT_SESSIONS) { } + ESessions() : LogEvent(EVENT_SESSIONS), old_style_encode(false) { } ESessions(version_t pv, map& 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) { diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 4a7c750b641d..3968eee7dac5 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1414,7 +1414,7 @@ void ESession::generate_test_instances(list& ls) } // ----------------------- -// ESession +// ESessions void ESessions::update_segment() {