From 83c1a3c4eb96f1bed4d42aa307a69d4097011885 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 31 Jan 2013 14:04:22 -0800 Subject: [PATCH] mds: EImportStart event uses modern encoding Signed-off-by: Greg Farnum --- src/mds/events/EImportStart.h | 27 +++++------------------- src/mds/journal.cc | 39 +++++++++++++++++++++++++++++++++++ src/test/encoding/types.h | 2 ++ 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/mds/events/EImportStart.h b/src/mds/events/EImportStart.h index eaf606a9fcf5c..0f55190139c9d 100644 --- a/src/mds/events/EImportStart.h +++ b/src/mds/events/EImportStart.h @@ -40,31 +40,14 @@ protected: metablob(log) { } EImportStart() : LogEvent(EVENT_IMPORTSTART) { } - void print(ostream& out) { + void print(ostream& out) const { out << "EImportStart " << base << " " << metablob; } - void encode(bufferlist &bl) const { - __u8 struct_v = 2; - ::encode(struct_v, bl); - ::encode(stamp, bl); - ::encode(base, bl); - ::encode(metablob, bl); - ::encode(bounds, bl); - ::encode(cmapv, bl); - ::encode(client_map, bl); - } - void decode(bufferlist::iterator &bl) { - __u8 struct_v; - ::decode(struct_v, bl); - if (struct_v >= 2) - ::decode(stamp, bl); - ::decode(base, bl); - ::decode(metablob, bl); - ::decode(bounds, bl); - ::decode(cmapv, bl); - ::decode(client_map, 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 2e517f4cf700e..c0d3d049709ab 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1503,6 +1503,45 @@ void EImportStart::replay(MDS *mds) update_segment(); } +void EImportStart::encode(bufferlist &bl) const { + ENCODE_START(3, 3, bl); + ::encode(stamp, bl); + ::encode(base, bl); + ::encode(metablob, bl); + ::encode(bounds, bl); + ::encode(cmapv, bl); + ::encode(client_map, bl); + ENCODE_FINISH(bl); +} + +void EImportStart::decode(bufferlist::iterator &bl) { + DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); + if (struct_v >= 2) + ::decode(stamp, bl); + ::decode(base, bl); + ::decode(metablob, bl); + ::decode(bounds, bl); + ::decode(cmapv, bl); + ::decode(client_map, bl); + DECODE_FINISH(bl); +} + +void EImportStart::dump(Formatter *f) const +{ + f->dump_stream("base dirfrag") << base; + f->open_array_section("boundary dirfrags"); + for (vector::const_iterator iter = bounds.begin(); + iter != bounds.end(); ++iter) { + f->dump_stream("frag") << *iter; + } + f->close_section(); +} + +void EImportStart::generate_test_instances(list& ls) +{ + ls.push_back(new EImportStart); +} + // ----------------------- // EImportFinish diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index dc90de4d2d391..a6d185d76a03e 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -131,6 +131,8 @@ TYPE(EExport) TYPE(EFragment) #include "mds/events/EImportFinish.h" TYPE(EImportFinish) +#include "mds/events/EImportStart.h" +TYPE(EImportStart) #ifdef WITH_RADOSGW -- 2.39.5