From d21de8108c67a6ee2ffae1502610b930e63d254c Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 5 Feb 2013 11:39:14 -0800 Subject: [PATCH] mds: ECommitted now uses modern encoding Signed-off-by: Sage Weil Signed-off-by: Greg Farnum --- src/mds/events/ECommitted.h | 17 ++++------------- src/mds/journal.cc | 28 ++++++++++++++++++++++++++++ src/test/encoding/types.h | 3 +++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/mds/events/ECommitted.h b/src/mds/events/ECommitted.h index dfc84a515e735..0cb933e2389b9 100644 --- a/src/mds/events/ECommitted.h +++ b/src/mds/events/ECommitted.h @@ -30,19 +30,10 @@ public: out << "ECommitted " << reqid; } - void encode(bufferlist &bl) const { - __u8 struct_v = 2; - ::encode(struct_v, bl); - ::encode(stamp, bl); - ::encode(reqid, bl); - } - void decode(bufferlist::iterator &bl) { - __u8 struct_v; - ::decode(struct_v, bl); - if (struct_v >= 2) - ::decode(stamp, bl); - ::decode(reqid, bl); - } + void encode(bufferlist &bl) const; + void decode(bufferlist::iterator &bl); + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); void update_segment() {} void replay(MDS *mds); diff --git a/src/mds/journal.cc b/src/mds/journal.cc index d08a9a4415247..8e522279d10e7 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1112,7 +1112,35 @@ void ECommitted::replay(MDS *mds) } } +void ECommitted::encode(bufferlist& bl) const +{ + ENCODE_START(3, 3, bl); + ::encode(stamp, bl); + ::encode(reqid, bl); + ENCODE_FINISH(bl); +} + +void ECommitted::decode(bufferlist::iterator& bl) +{ + DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); + if (struct_v >= 2) + ::decode(stamp, bl); + ::decode(reqid, bl); + DECODE_FINISH(bl); +} +void ECommitted::dump(Formatter *f) const { + f->dump_stream("stamp") << stamp; + f->dump_stream("reqid") << reqid; +} + +void ECommitted::generate_test_instances(list& ls) +{ + ls.push_back(new ECommitted); + ls.push_back(new ECommitted); + ls.back()->stamp = utime_t(1, 2); + ls.back()->reqid = metareqid_t(entity_name_t::CLIENT(123), 456); +} // ----------------------- // ESlaveUpdate diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 703afa9e27ad2..68fd7af2cc0ae 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -123,6 +123,9 @@ TYPE(Capability) #include "mds/AnchorServer.h" TYPE(AnchorServer) +#include "mds/events/ECommitted.h" +TYPE(ECommitted) + #ifdef WITH_RADOSGW #include "rgw/rgw_rados.h" -- 2.39.5