From: Greg Farnum Date: Thu, 17 Jan 2013 18:31:22 +0000 (-0800) Subject: mds: session_info_t now uses modern encoding X-Git-Tag: v0.58~100^2~60 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f57f4244950b9022ce65a9d7c99bc043a321f700;p=ceph.git mds: session_info_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 b562284a8a7..33a16b6afb4 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -511,22 +511,68 @@ void fnode_t::generate_test_instances(list& ls) */ void session_info_t::encode(bufferlist& bl) const { - __u8 v = 1; - ::encode(v, bl); + ENCODE_START(2, 2, bl); ::encode(inst, bl); ::encode(completed_requests, bl); ::encode(prealloc_inos, bl); // hacky, see below. ::encode(used_inos, bl); + ENCODE_FINISH(bl); } void session_info_t::decode(bufferlist::iterator& p) { - __u8 v; - ::decode(v, p); + DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p); ::decode(inst, p); ::decode(completed_requests, p); ::decode(prealloc_inos, p); ::decode(used_inos, p); prealloc_inos.insert(used_inos); used_inos.clear(); + DECODE_FINISH(p); +} + +void session_info_t::dump(Formatter *f) const +{ + f->dump_stream("inst") << inst; + + f->open_array_section("completed_requests"); + for (set::const_iterator p = completed_requests.begin(); + p != completed_requests.end(); + ++p) + f->dump_unsigned("tid", *p); + f->close_section(); + + f->open_array_section("prealloc_inos"); + for (interval_set::const_iterator p = prealloc_inos.begin(); + p != prealloc_inos.end(); + ++p) { + f->open_object_section("ino_range"); + f->dump_unsigned("start", p.get_start()); + f->dump_unsigned("length", p.get_len()); + f->close_section(); + } + f->close_section(); + + f->open_array_section("used_inos"); + for (interval_set::const_iterator p = prealloc_inos.begin(); + p != prealloc_inos.end(); + ++p) { + f->open_object_section("ino_range"); + f->dump_unsigned("start", p.get_start()); + f->dump_unsigned("length", p.get_len()); + f->close_section(); + } + f->close_section(); +} + +void session_info_t::generate_test_instances(list& ls) +{ + ls.push_back(new session_info_t); + ls.push_back(new session_info_t); + ls.back()->inst = entity_inst_t(entity_name_t::MDS(12), entity_addr_t()); + ls.back()->completed_requests.insert(234); + ls.back()->completed_requests.insert(237); + ls.back()->prealloc_inos.insert(333, 12); + ls.back()->prealloc_inos.insert(377, 112); + // we can't add used inos; they're cleared on decode } diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 37a767b65f9..2aa52001239 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -104,6 +104,7 @@ TYPE(client_writeable_range_t) TYPE(inode_t) TYPE(old_inode_t) TYPE(fnode_t) +TYPE(session_info_t) #ifdef WITH_RADOSGW