From: Greg Farnum Date: Fri, 25 Jan 2013 02:15:13 +0000 (-0800) Subject: mds: use modern encoding for LogEvent X-Git-Tag: v0.58~100^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4123d01120f2058e7b2bdcafaac66c5be4a45c74;p=ceph.git mds: use modern encoding for LogEvent It's a pretty simple encoding, but if we ever want to encode more than the event type and the event itself we'll be glad to have versioned the super-structure as well. Signed-off-by: Greg Farnum --- diff --git a/src/mds/LogEvent.cc b/src/mds/LogEvent.cc index 777c0a6ce6f..c4f18c756a9 100644 --- a/src/mds/LogEvent.cc +++ b/src/mds/LogEvent.cc @@ -42,8 +42,22 @@ LogEvent *LogEvent::decode(bufferlist& bl) // parse type, length bufferlist::iterator p = bl.begin(); __u32 type; + LogEvent *event = NULL; ::decode(type, p); + if (EVENT_NEW_ENCODING == type) { + DECODE_START(1, p); + ::decode(type, p); + event = decode_event(bl, p, type); + DECODE_FINISH(p); + } else { // we are using classic encoding + event = decode_event(bl, p, type); + } + return event; +} + +LogEvent *LogEvent::decode_event(bufferlist& bl, bufferlist::iterator& p, __u32 type) +{ int length = bl.length() - p.get_off(); generic_dout(15) << "decode_log_event type " << type << ", size " << length << dendl; diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h index 98d95d4314c..25990b6f104 100644 --- a/src/mds/LogEvent.h +++ b/src/mds/LogEvent.h @@ -15,6 +15,7 @@ #ifndef CEPH_LOGEVENT_H #define CEPH_LOGEVENT_H +#define EVENT_NEW_ENCODING 0 // indicates that the encoding is versioned #define EVENT_UNUSED 1 // was previously EVENT_STRING #define EVENT_SUBTREEMAP 2 @@ -55,6 +56,7 @@ class LogEvent { private: __u32 _type; uint64_t _start_off; + static LogEvent *decode_event(bufferlist& bl, bufferlist::iterator& p, __u32 type); protected: utime_t stamp; @@ -83,8 +85,11 @@ protected: static LogEvent *decode(bufferlist &bl); void encode_with_header(bufferlist& bl) { + ::encode(EVENT_NEW_ENCODING, bl); + ENCODE_START(1, 1, bl) ::encode(_type, bl); encode(bl); + ENCODE_FINISH(bl); } virtual void print(ostream& out) {