From: Greg Farnum Date: Thu, 17 Jan 2013 18:30:49 +0000 (-0800) Subject: mds: fnode_t now uses modern encoding X-Git-Tag: v0.58~100^2~62 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=44865800fc9297cb4d018d40555623efea2a6ba2;p=ceph.git mds: fnode_t now uses modern encoding Signed-off-by: Sage Weil Signed-off-by: Greg Farnum --- diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 1cb34f6a1a4..120dbacc408 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -438,3 +438,69 @@ void old_inode_t::generate_test_instances(list& ls) ls.back()->xattrs["user.foo"] = buffer::copy("asdf", 4); ls.back()->xattrs["user.unprintable"] = buffer::copy("\000\001\002", 3); } + + +/* + * fnode_t + */ +void fnode_t::encode(bufferlist &bl) const +{ + ENCODE_START(2, 2, bl); + ::encode(version, bl); + ::encode(snap_purged_thru, bl); + ::encode(fragstat, bl); + ::encode(accounted_fragstat, bl); + ::encode(rstat, bl); + ::encode(accounted_rstat, bl); + ENCODE_FINISH(bl); +} + +void fnode_t::decode(bufferlist::iterator &bl) +{ + DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); + ::decode(version, bl); + ::decode(snap_purged_thru, bl); + ::decode(fragstat, bl); + ::decode(accounted_fragstat, bl); + ::decode(rstat, bl); + ::decode(accounted_rstat, bl); + DECODE_FINISH(bl); +} + +void fnode_t::dump(Formatter *f) const +{ + f->dump_unsigned("version", version); + f->dump_unsigned("snap_purged_thru", snap_purged_thru); + + f->open_object_section("fragstat"); + fragstat.dump(f); + f->close_section(); + + f->open_object_section("accounted_fragstat"); + accounted_fragstat.dump(f); + f->close_section(); + + f->open_object_section("rstat"); + rstat.dump(f); + f->close_section(); + + f->open_object_section("accounted_rstat"); + accounted_rstat.dump(f); + f->close_section(); +} + +void fnode_t::generate_test_instances(list& ls) +{ + ls.push_back(new fnode_t); + ls.push_back(new fnode_t); + ls.back()->version = 1; + ls.back()->snap_purged_thru = 2; + list fls; + frag_info_t::generate_test_instances(fls); + ls.back()->fragstat = *fls.back(); + ls.back()->accounted_fragstat = *fls.front(); + list nls; + nest_info_t::generate_test_instances(nls); + ls.back()->rstat = *nls.front(); + ls.back()->accounted_rstat = *nls.back(); +} diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index d0e70402334..c4cafd6d4fd 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -459,26 +459,10 @@ struct fnode_t { frag_info_t fragstat, accounted_fragstat; nest_info_t rstat, accounted_rstat; - void encode(bufferlist &bl) const { - __u8 v = 1; - ::encode(v, bl); - ::encode(version, bl); - ::encode(snap_purged_thru, bl); - ::encode(fragstat, bl); - ::encode(accounted_fragstat, bl); - ::encode(rstat, bl); - ::encode(accounted_rstat, bl); - } - void decode(bufferlist::iterator &bl) { - __u8 v; - ::decode(v, bl); - ::decode(version, bl); - ::decode(snap_purged_thru, bl); - ::decode(fragstat, bl); - ::decode(accounted_fragstat, bl); - ::decode(rstat, bl); - ::decode(accounted_rstat, bl); - } + void encode(bufferlist &bl) const; + void decode(bufferlist::iterator& bl); + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); }; WRITE_CLASS_ENCODER(fnode_t) diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 47179f30f21..37a767b65f9 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -103,7 +103,7 @@ TYPE(nest_info_t) TYPE(client_writeable_range_t) TYPE(inode_t) TYPE(old_inode_t) - +TYPE(fnode_t) #ifdef WITH_RADOSGW