From d82f1009c34af1577d8e63c43b1b94feab085d55 Mon Sep 17 00:00:00 2001 From: sageweil Date: Sat, 29 Sep 2007 20:12:50 +0000 Subject: [PATCH] encode/decode_simple, streamlined MClientReply::InodeStat encoding git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1873 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/Makefile | 2 +- branches/sage/mds/include/buffer.h | 8 +- branches/sage/mds/include/encodable.h | 312 ++++++++++++++++-- branches/sage/mds/include/frag.h | 4 + branches/sage/mds/mds/Server.cc | 34 +- branches/sage/mds/mds/mdstypes.h | 5 + branches/sage/mds/messages/MClientReply.h | 220 ++++++------ branches/sage/mds/messages/MMDSCacheRejoin.h | 40 +-- branches/sage/mds/messages/MMDSSlaveRequest.h | 26 +- 9 files changed, 435 insertions(+), 216 deletions(-) diff --git a/branches/sage/mds/Makefile b/branches/sage/mds/Makefile index 0b486be4efab9..0aed7bc169172 100644 --- a/branches/sage/mds/Makefile +++ b/branches/sage/mds/Makefile @@ -13,7 +13,7 @@ # on issdm, it's /usr/local/mpich2/bin. # Hook for extra -I options, etc. -EXTRA_CFLAGS = -O3 -pg -g #-I${HOME}/include -L${HOME}/lib +EXTRA_CFLAGS = -pg -g #-I${HOME}/include -L${HOME}/lib # base CFLAGS = -Wall -I. -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE ${EXTRA_CFLAGS} diff --git a/branches/sage/mds/include/buffer.h b/branches/sage/mds/include/buffer.h index 0e165cec82b51..b6255d6ace457 100644 --- a/branches/sage/mds/include/buffer.h +++ b/branches/sage/mds/include/buffer.h @@ -441,6 +441,10 @@ public: unsigned get_off() { return off; } + bool end() { + return p == ls.end(); + } + void advance(unsigned o) { //cout << this << " advance " << o << " from " << off << " (p_off " << p_off << " in " << p->length() << ")" << std::endl; p_off += o; @@ -946,7 +950,9 @@ inline std::ostream& operator<<(std::ostream& out, const buffer::list& bl) { // ---------------------------------------------------------- -// new encoders +// encoders + +// DEPRECATED, please use _(en|de)code_(simple|complex) // raw template diff --git a/branches/sage/mds/include/encodable.h b/branches/sage/mds/include/encodable.h index 5d53c80adbda0..321361866ec9b 100644 --- a/branches/sage/mds/include/encodable.h +++ b/branches/sage/mds/include/encodable.h @@ -24,24 +24,276 @@ #include #include + +// ================================================================== +// simple + + +// raw +template +inline void _encode_raw(const T& t, bufferlist& bl) +{ + bl.append((char*)&t, sizeof(t)); +} +template +inline void _decode_raw(T& t, bufferlist::iterator &p) +{ + p.copy(sizeof(t), (char*)&t); +} + +#include +#include +#include +#include +#include +#include + +// list +template +inline void _encode_simple(const std::list& ls, bufferlist& bl) +{ + // should i pre- or post- count? + if (!ls.empty()) { + unsigned pos = bl.length(); + uint32_t n = 0; + _encode_raw(n, bl); + for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) { + n++; + _encode_simple(*p, bl); + } + bl.copy_in(pos, sizeof(n), (char*)&n); + } else { + uint32_t n = ls.size(); // FIXME: this is slow on a list. + _encode_raw(n, bl); + for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) + _encode_simple(*p, bl); + } +} +template +inline void _decode_simple(std::list& ls, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + ls.clear(); + while (n--) { + T v; + _decode_simple(v, p); + ls.push_back(v); + } +} + +// deque +template +inline void _encode_simple(const std::deque& ls, bufferlist& bl) +{ + uint32_t n = ls.size(); + _encode_raw(n, bl); + for (typename std::deque::const_iterator p = ls.begin(); p != ls.end(); ++p) + _encode_simple(*p, bl); +} +template +inline void _decode_simple(std::deque& ls, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + ls.clear(); + while (n--) { + T v; + _decode_simple(v, p); + ls.push_back(v); + } +} + +// set +template +inline void _encode_simple(const std::set& s, bufferlist& bl) +{ + uint32_t n = s.size(); + _encode_raw(n, bl); + for (typename std::set::const_iterator p = s.begin(); p != s.end(); ++p) + _encode_simple(*p, bl); +} +template +inline void _decode_simple(std::set& s, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + s.clear(); + while (n--) { + T v; + _decode_simple(v, p); + s.insert(v); + } +} + +// vector +template +inline void _encode_simple(const std::vector& v, bufferlist& bl) +{ + uint32_t n = v.size(); + _encode_raw(n, bl); + for (typename std::vector::const_iterator p = v.begin(); p != v.end(); ++p) + _encode_simple(*p, bl); +} +template +inline void _decode_simple(std::vector& v, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + v.resize(n); + for (uint32_t i=0; i +inline void _encode_simple(const std::map& m, bufferlist& bl) +{ + uint32_t n = m.size(); + _encode_raw(n, bl); + for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { + _encode_simple(p->first, bl); + _encode_simple(p->second, bl); + } +} +template +inline void _decode_simple(std::map& m, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + m.clear(); + while (n--) { + T k; + _decode_simple(k, p); + _decode_simple(m[k], p); + } +} + +// hash_map +template +inline void _encode_simple(const __gnu_cxx::hash_map& m, bufferlist& bl) +{ + uint32_t n = m.size(); + _encode_raw(n, bl); + for (typename __gnu_cxx::hash_map::const_iterator p = m.begin(); p != m.end(); ++p) { + _encode_simple(p->first, bl); + _encode_simple(p->second, bl); + } +} +template +inline void _decode_simple(__gnu_cxx::hash_map& m, bufferlist::iterator& p) +{ + uint32_t n; + _decode_raw(n, p); + m.clear(); + while (n--) { + T k; + _decode_simple(k, p); + _decode_simple(m[k], p); + } +} + +// string +inline void _encode_simple(const std::string& s, bufferlist& bl) +{ + uint32_t len = s.length(); + _encode_raw(len, bl); + bl.append(s.data(), len); +} +inline void _decode_simple(std::string& s, bufferlist::iterator& p) +{ + uint32_t len; + _decode_raw(len, p); + s.clear(); + p.copy(len, s); +} + +// const char* (encode only, string compatible) +inline void _encode_simple(const char *s, bufferlist& bl) +{ + uint32_t len = strlen(s); + _encode_raw(len, bl); + bl.append(s, len); +} + +// bufferptr (encapsulated) +inline void _encode_simple(const buffer::ptr& bp, bufferlist& bl) +{ + uint32_t len = bp.length(); + _encode_raw(len, bl); + bl.append(bp); +} +inline void _decode_simple(buffer::ptr& bp, bufferlist::iterator& p) +{ + uint32_t len; + _decode_raw(len, p); + + bufferlist s; + p.copy(len, s); + + if (s.buffers().size() == 1) + bp = s.buffers().front(); + else + bp = buffer::copy(s.c_str(), s.length()); +} + +// bufferlist (encapsulated) +inline void _encode_simple(const bufferlist& s, bufferlist& bl) +{ + uint32_t len = s.length(); + _encode_raw(len, bl); + bl.append(s); +} +inline void _encode_simple_destructively(bufferlist& s, bufferlist& bl) +{ + uint32_t len = s.length(); + _encode_raw(len, bl); + bl.claim_append(s); +} +inline void _decode_simple(bufferlist& s, bufferlist::iterator& p) +{ + uint32_t len; + _decode_raw(len, p); + s.clear(); + p.copy(len, s); +} + +// base +template +inline void _encode_simple(const T& t, bufferlist& bl) +{ + _encode_raw(t, bl); +} +template +inline void _decode_simple(T& t, bufferlist::iterator& p) +{ + _decode_raw(t, p); +} + + + + +// ================================================================== +// complex + // list template inline void _encode_complex(const std::list& ls, bufferlist& bl) { uint32_t n = ls.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) _encode_complex(*p, bl); } template -inline void _decode_complex(std::list& ls, bufferlist& bl, int& off) +inline void _decode_complex(std::list& ls, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); ls.clear(); while (n--) { T v; - _decode_complex(v, bl, off); + _decode_complex(v, p); ls.push_back(v); } } @@ -51,19 +303,19 @@ template inline void _encode_complex(const std::deque& ls, bufferlist& bl) { uint32_t n = ls.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename std::deque::const_iterator p = ls.begin(); p != ls.end(); ++p) _encode_complex(*p, bl); } template -inline void _decode_complex(std::deque& ls, bufferlist& bl, int& off) +inline void _decode_complex(std::deque& ls, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); ls.clear(); while (n--) { T v; - _decode_complex(v, bl, off); + _decode_complex(v, p); ls.push_back(v); } } @@ -73,19 +325,19 @@ template inline void _encode_complex(const std::set& s, bufferlist& bl) { uint32_t n = s.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename std::set::const_iterator p = s.begin(); p != s.end(); ++p) _encode_complex(*p, bl); } template -inline void _decode_complex(std::set& s, bufferlist& bl, int& off) +inline void _decode_complex(std::set& s, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); s.clear(); while (n--) { T v; - _decode_complex(v, bl, off); + _decode_complex(v, p); s.insert(v); } } @@ -95,18 +347,18 @@ template inline void _encode_complex(const std::vector& v, bufferlist& bl) { uint32_t n = v.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename std::vector::const_iterator p = v.begin(); p != v.end(); ++p) _encode_complex(*p, bl); } template -inline void _decode_complex(std::vector& v, bufferlist& bl, int& off) +inline void _decode_complex(std::vector& v, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); v.resize(n); for (uint32_t i=0; i inline void _encode_complex(const std::map& m, bufferlist& bl) { uint32_t n = m.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { - _encode(p->first, bl); + _encode_simple(p->first, bl); _encode_complex(p->second, bl); } } template -inline void _decode_complex(std::map& m, bufferlist& bl, int& off) +inline void _decode_complex(std::map& m, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); m.clear(); while (n--) { T k; - _decode(k, bl, off); - _decode_complex(m[k], bl, off); + _decode_simple(k, p); + _decode_complex(m[k], p); } } @@ -138,22 +390,22 @@ template inline void _encode_complex(const __gnu_cxx::hash_map& m, bufferlist& bl) { uint32_t n = m.size(); - _encoderaw(n, bl); + _encode_raw(n, bl); for (typename __gnu_cxx::hash_map::const_iterator p = m.begin(); p != m.end(); ++p) { - _encode(p->first, bl); + _encode_simple(p->first, bl); _encode_complex(p->second, bl); } } template -inline void _decode_complex(__gnu_cxx::hash_map& m, bufferlist& bl, int& off) +inline void _decode_complex(__gnu_cxx::hash_map& m, bufferlist::iterator& p) { uint32_t n; - _decoderaw(n, bl, off); + _decode_raw(n, p); m.clear(); while (n--) { T k; - _decode(k, bl, off); - _decode_complex(m[k], bl, off); + _decode_simple(k, p); + _decode_complex(m[k], p); } } @@ -164,9 +416,9 @@ inline void _encode_complex(const T& t, bufferlist& bl) t._encode(bl); } template -inline void _decode_complex(T& t, bufferlist& bl, int& off) +inline void _decode_complex(T& t, bufferlist::iterator& p) { - t._decode(bl, off); + t._decode(p); } #endif diff --git a/branches/sage/mds/include/frag.h b/branches/sage/mds/include/frag.h index a6f5fdbde4b52..333730d64fe7c 100644 --- a/branches/sage/mds/include/frag.h +++ b/branches/sage/mds/include/frag.h @@ -20,6 +20,7 @@ #include #include #include "buffer.h" +#include "encodable.h" /* * @@ -462,6 +463,9 @@ class fragtree_t { void _decode(bufferlist& bl, int& off) { ::_decode(_splits, bl, off); } + void _decode(bufferlist::iterator& p) { + ::_decode_simple(_splits, p); + } void print(std::ostream& out) { out << "fragtree_t("; diff --git a/branches/sage/mds/mds/Server.cc b/branches/sage/mds/mds/Server.cc index 27c8aa9d21e05..aad364d9468b3 100644 --- a/branches/sage/mds/mds/Server.cc +++ b/branches/sage/mds/mds/Server.cc @@ -1567,8 +1567,7 @@ void Server::handle_client_readdir(MDRequest *mdr) } // build dir contents - list inls; - list dnls; + bufferlist dirbl; int numfiles = 0; for (CDir::map_t::iterator it = dir->begin(); @@ -1601,29 +1600,14 @@ void Server::handle_client_readdir(MDRequest *mdr) } assert(in); - InodeStat *st; - if (in) { - dout(12) << "including inode " << *in << dendl; - - // add this item - // note: InodeStat makes note of whether inode data is readable. - st = new InodeStat(in, mds->get_nodeid()); - } else { - assert(0); - /* - assert(dn->is_remote()); - dout(12) << "including inode-less (remote) dentry " << *dn << dendl; - st = new InodeStat; - st->mask = STAT_MASK_INO | STAT_MASK_TYPE; - memset(&st->inode, 0, sizeof(st->inode)); - st->inode.ino = dn->get_remote_ino(); - st->inode.mode = DT_TO_MODE(dn->get_remote_d_type()); - */ - } + + assert(in); - dnls.push_back( it->first ); - inls.push_back(st); - numfiles++; + dout(12) << "including inode " << *in << dendl; + + // add this dentry + inodeinfo + ::_encode(it->first, dirbl); + InodeStat::_encode(dirbl, in, mds->get_nodeid()); // touch it mdcache->lru.lru_touch(dn); @@ -1631,7 +1615,7 @@ void Server::handle_client_readdir(MDRequest *mdr) // yay, reply MClientReply *reply = new MClientReply(req); - reply->take_dir_items(dnls, inls, numfiles); + reply->take_dir_items(dirbl); dout(10) << "reply to " << *req << " readdir " << numfiles << " files" << dendl; reply->set_result(0); diff --git a/branches/sage/mds/mds/mdstypes.h b/branches/sage/mds/mds/mdstypes.h index b7e69c91296e7..a0f70ff421e84 100644 --- a/branches/sage/mds/mds/mdstypes.h +++ b/branches/sage/mds/mds/mdstypes.h @@ -357,6 +357,11 @@ public: ::_decode(dirfrag, bl, off); ::_decode(dname, bl, off); } + void _decode(bufferlist::iterator& p) { + ::_decode_simple(ino, p); + ::_decode_simple(dirfrag, p); + ::_decode_simple(dname, p); + } }; diff --git a/branches/sage/mds/messages/MClientReply.h b/branches/sage/mds/messages/MClientReply.h index 24b7eae8976b7..a9efaaa2ea602 100644 --- a/branches/sage/mds/messages/MClientReply.h +++ b/branches/sage/mds/messages/MClientReply.h @@ -17,7 +17,7 @@ #define __MCLIENTREPLY_H #include "include/types.h" - +#include "include/encodable.h" #include "MClientRequest.h" #include "msg/Message.h" @@ -64,23 +64,36 @@ class InodeStat { public: InodeStat() {} - InodeStat(CInode *in, int whoami) : - inode(in->inode), - mask(STAT_MASK_INO|STAT_MASK_TYPE|STAT_MASK_BASE) - { + InodeStat(bufferlist::iterator& p) { + _decode(p); + } + + void _decode(bufferlist::iterator &p) { + ::_decode_simple(mask, p); + ::_decode_simple(inode, p); + ::_decode_simple(dirfrag_auth, p); + ::_decode_simple(dirfrag_dist, p); + ::_decode_simple(dirfrag_rep, p); + ::_decode_simple(symlink, p); + dirfragtree._decode(p); + } + + static void _encode(bufferlist &bl, CInode *in, int whoami) { + int mask = STAT_MASK_INO|STAT_MASK_TYPE|STAT_MASK_BASE; + // mask if (in->authlock.can_rdlock(0)) mask |= STAT_MASK_AUTH; if (in->linklock.can_rdlock(0)) mask |= STAT_MASK_LINK; if (in->filelock.can_rdlock(0)) mask |= STAT_MASK_FILE; - - // symlink content? - if (in->is_symlink()) - symlink = in->symlink; - - // dirfragtree - dirfragtree = in->dirfragtree; - + + ::_encode_simple(mask, bl); + ::_encode_simple(in->inode, bl); + // dirfrag info + map dirfrag_auth; + map > dirfrag_dist; + set dirfrag_rep; + list ls; in->get_dirfrags(ls); for (list::iterator p = ls.begin(); @@ -93,50 +106,38 @@ class InodeStat { if (dir->is_rep()) dirfrag_rep.insert(dir->dirfrag().frag); } + + ::_encode_simple(dirfrag_auth, bl); + ::_encode_simple(dirfrag_dist, bl); + ::_encode_simple(dirfrag_rep, bl); + + ::_encode_simple(in->symlink, bl); + in->dirfragtree._encode(bl); } - void _encode(bufferlist &bl) { - ::_encode(mask, bl); - ::_encode(inode, bl); - ::_encode(dirfrag_auth, bl); - ::_encode(dirfrag_dist, bl); - ::_encode(dirfrag_rep, bl); - ::_encode(symlink, bl); - dirfragtree._encode(bl); - } - - void _decode(bufferlist &bl, int& off) { - ::_decode(mask, bl, off); - ::_decode(inode, bl, off); - ::_decode(dirfrag_auth, bl, off); - ::_decode(dirfrag_dist, bl, off); - ::_decode(dirfrag_rep, bl, off); - ::_decode(symlink, bl, off); - dirfragtree._decode(bl, off); - } }; class MClientReply : public Message { // reply data - struct { + struct st_ { long tid; int op; int result; // error code unsigned char file_caps; // for open long file_caps_seq; uint64_t file_data_version; // for client buffercache consistency - - int _num_trace_in; - int _dir_size; } st; string path; + list trace_in; list trace_dn; + bufferlist trace_bl; - list dir_dn; list dir_in; + list dir_dn; + bufferlist dir_bl; public: long get_tid() { return st.tid; } @@ -148,12 +149,6 @@ class MClientReply : public Message { inodeno_t get_ino() { return trace_in.back()->inode.ino; } const inode_t& get_inode() { return trace_in.back()->inode; } - const list& get_trace_in() { return trace_in; } - const list& get_trace_dn() { return trace_dn; } - - const list& get_dir_in() { return dir_in; } - const list& get_dir_dn() { return dir_dn; } - unsigned char get_file_caps() { return st.file_caps; } long get_file_caps_seq() { return st.file_caps_seq; } uint64_t get_file_data_version() { return st.file_data_version; } @@ -172,9 +167,6 @@ class MClientReply : public Message { this->path = req->get_path(); this->st.result = result; - - st._dir_size = 0; - st._num_trace_in = 0; } virtual ~MClientReply() { list::iterator it; @@ -195,100 +187,76 @@ class MClientReply : public Message { // serialization virtual void decode_payload() { - int off = 0; - payload.copy(off, sizeof(st), (char*)&st); - off += sizeof(st); - - _decode(path, payload, off); - - for (int i=0; i_decode(payload, off); - trace_in.push_back(ci); - } - - // dir contents - ::_decode(dir_dn, payload, off); - for (int i=0; i_decode(payload, off); - dir_in.push_back(ci); - } + bufferlist::iterator p = payload.begin(); + ::_decode_simple(st, p); + ::_decode_simple(path, p); + ::_decode_simple(trace_bl, p); + ::_decode_simple(dir_bl, p); + assert(p.end()); } virtual void encode_payload() { - payload.append((char*)&st, sizeof(st)); - _encode(path, payload); - - // trace - list::iterator pdn = trace_dn.begin(); - list::iterator pin; - for (pin = trace_in.begin(); - pin != trace_in.end(); - ++pin) { - if (pin != trace_in.begin()) { - ::_encode(*pdn, payload); - ++pdn; - } - (*pin)->_encode(payload); - } - - // dir contents - ::_encode(dir_dn, payload); - for (pin = dir_in.begin(); - pin != dir_in.end(); - ++pin) - (*pin)->_encode(payload); + ::_encode_simple(st, payload); + ::_encode_simple(path, payload); + ::_encode_simple(trace_bl, payload); + ::_encode_simple(dir_bl, payload); } - // builders - /* - void add_dir_item(string& dn, InodeStat *in) { - dir_dn.push_back(dn); - dir_in.push_back(in); - ++st._dir_size; - }*/ - void take_dir_items(list& dnls, - list& inls, - int num) { - dir_dn.swap(dnls); - dir_in.swap(inls); - st._dir_size = num; + + // dir contents + void take_dir_items(bufferlist& bl) { + dir_bl.claim(bl); } - /* - void copy_dir_items(const list& inls, - const list& dnls) { - list::const_iterator pdn = dnls.begin(); - list::const_iterator pin = inls.begin(); - while (pin != inls.end()) { - // copy! - InodeStat *i = new InodeStat; - *i = **pin; - dir_in.push_back(i); - dir_dn.push_back(*pdn); - ++pin; - ++pdn; - ++st._dir_size; + void _decode_dir() { + bufferlist::iterator p = dir_bl.begin(); + while (!p.end()) { + string dn; + ::_decode_simple(dn, p); + dir_dn.push_back(dn); + dir_in.push_back(new InodeStat(p)); } } - */ + const list& get_dir_in() { + if (dir_in.empty() && dir_bl.length()) _decode_dir(); + return dir_in; + } + const list& get_dir_dn() { + if (dir_dn.empty() && dir_bl.length()) _decode_dir(); + return dir_dn; + } + + + // trace void set_trace_dist(CInode *in, int whoami) { - st._num_trace_in = 0; + // inode, dentry, ..., inode while (in) { - // add this inode to trace, along with referring dentry name + InodeStat::_encode(trace_bl, in, whoami); if (in->get_parent_dn()) - trace_dn.push_front(in->get_parent_dn()->get_name()); - trace_in.push_front(new InodeStat(in, whoami)); - ++st._num_trace_in; - + ::_encode_simple(in->get_parent_dn()->get_name(), trace_bl); in = in->get_parent_inode(); } } + void _decode_trace() { + bufferlist::iterator p = trace_bl.begin(); + while (!p.end()) { + trace_in.push_front(new InodeStat(p)); + if (!p.end()) { + string ref_dn; + ::_decode_simple(ref_dn, p); + trace_dn.push_front(ref_dn); + } + } + } + + const list& get_trace_in() { + if (trace_in.empty() && trace_bl.length()) _decode_trace(); + return trace_in; + } + const list& get_trace_dn() { + if (trace_in.empty() && trace_bl.length()) _decode_trace(); + return trace_dn; + } + }; diff --git a/branches/sage/mds/messages/MMDSCacheRejoin.h b/branches/sage/mds/messages/MMDSCacheRejoin.h index c2d26ed23f45a..5a04e9afa1973 100644 --- a/branches/sage/mds/messages/MMDSCacheRejoin.h +++ b/branches/sage/mds/messages/MMDSCacheRejoin.h @@ -64,10 +64,10 @@ class MMDSCacheRejoin : public Message { inode_full(const inode_t& i, const string& s, const fragtree_t& f) : inode(i), symlink(s), dirfragtree(f) {} - void _decode(bufferlist& bl, int& off) { - ::_decode(inode, bl, off); - ::_decode(symlink, bl, off); - ::_decode(dirfragtree, bl, off); + void _decode(bufferlist::iterator& p) { + ::_decode_simple(inode, p); + ::_decode_simple(symlink, p); + ::_decode_simple(dirfragtree, p); } void _encode(bufferlist& bl) const { ::_encode(inode, bl); @@ -205,24 +205,24 @@ class MMDSCacheRejoin : public Message { ::_encode(xlocked_dentries, payload); } void decode_payload() { - int off = 0; - ::_decode(op, payload, off); - ::_decode(strong_inodes, payload, off); - ::_decode_complex(full_inodes, payload, off); - ::_decode(authpinned_inodes, payload, off); - ::_decode(xlocked_inodes, payload, off); - ::_decode(cap_export_bl, payload, off); + bufferlist::iterator p = payload.begin(); + ::_decode_simple(op, p); + ::_decode_simple(strong_inodes, p); + ::_decode_complex(full_inodes, p); + ::_decode_simple(authpinned_inodes, p); + ::_decode_simple(xlocked_inodes, p); + ::_decode_simple(cap_export_bl, p); if (cap_export_bl.length()) { - int off = 0; - ::_decode(cap_exports, cap_export_bl, off); - ::_decode(cap_export_paths, cap_export_bl, off); + bufferlist::iterator q = cap_export_bl.begin(); + ::_decode_simple(cap_exports, q); + ::_decode_simple(cap_export_paths, q); } - ::_decode(strong_dirfrags, payload, off); - ::_decode(weak, payload, off); - ::_decode(weak_inodes, payload, off); - ::_decode(strong_dentries, payload, off); - ::_decode(authpinned_dentries, payload, off); - ::_decode(xlocked_dentries, payload, off); + ::_decode_simple(strong_dirfrags, p); + ::_decode_simple(weak, p); + ::_decode_simple(weak_inodes, p); + ::_decode_simple(strong_dentries, p); + ::_decode_simple(authpinned_dentries, p); + ::_decode_simple(xlocked_dentries, p); } }; diff --git a/branches/sage/mds/messages/MMDSSlaveRequest.h b/branches/sage/mds/messages/MMDSSlaveRequest.h index e2dbbd8f7298a..25ec82a86256f 100644 --- a/branches/sage/mds/messages/MMDSSlaveRequest.h +++ b/branches/sage/mds/messages/MMDSSlaveRequest.h @@ -123,19 +123,19 @@ public: ::_encode(stray, payload); } void decode_payload() { - int off = 0; - ::_decode(reqid, payload, off); - ::_decode(op, payload, off); - ::_decode(lock_type, payload, off); - object_info._decode(payload, off); - ::_decode_complex(authpins, payload, off); - ::_decode(srcdnpath, payload, off); - ::_decode(destdnpath, payload, off); - ::_decode(srcdn_replicas, payload, off); - ::_decode(now, payload, off); - ::_decode(inode_export, payload, off); - ::_decode(inode_export_v, payload, off); - ::_decode(stray, payload, off); + bufferlist::iterator p = payload.begin(); + ::_decode_simple(reqid, p); + ::_decode_simple(op, p); + ::_decode_simple(lock_type, p); + object_info._decode(p); + ::_decode_complex(authpins, p); + ::_decode_simple(srcdnpath, p); + ::_decode_simple(destdnpath, p); + ::_decode_simple(srcdn_replicas, p); + ::_decode_simple(now, p); + ::_decode_simple(inode_export, p); + ::_decode_simple(inode_export_v, p); + ::_decode_simple(stray, p); } char *get_type_name() { return "slave_request"; } -- 2.39.5