mon: add struct encoding v to ease future revisions

This commit is contained in:
Sage Weil 2010-01-25 10:29:24 -08:00
parent 90bfb992a1
commit e49a67302d
8 changed files with 60 additions and 1 deletions

View File

@ -156,6 +156,8 @@ void handle_notify(MMonObserveNotify *notify)
dout(0) << " log " << summary.tail.back() << dendl;
} else {
LogEntry le;
__u8 v;
::decode(v, p);
while (!p.end()) {
le.decode(p);
dout(0) << " log " << le << dendl;
@ -181,7 +183,8 @@ void handle_notify(MMonObserveNotify *notify)
}
} else {
ClassInfo info;
__u8 v;
::decode(v, p);
while (!p.end()) {
info.decode(p);
dout(0) << " class " << info << dendl;

View File

@ -26,10 +26,14 @@ struct ClassImpl {
version_t seq;
void encode(bufferlist& bl) const {
__u8 v = 0;
::encode(v, bl);
::encode(binary, bl);
::encode(seq, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
::decode(binary, bl);
::decode(seq, bl);
}
@ -44,10 +48,14 @@ struct ClassInfo {
ClassVersion version;
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
::encode(name, bl);
::encode(version, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
::decode(name, bl);
::decode(version, bl);
}
@ -68,12 +76,16 @@ struct ClassLibraryIncremental {
bufferlist impl;
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
__u32 _op = (__u32)op;
::encode(_op, bl);
::encode(info, bl);
::encode(impl, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
__u32 _op;
::decode(_op, bl);
op = (ClassLibraryIncOp)_op;
@ -103,9 +115,13 @@ public:
string default_ver;
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
::encode(m, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
::decode(m, bl);
}
@ -172,10 +188,14 @@ struct ClassLibrary {
return (info != NULL);
}
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
::encode(version, bl);
::encode(library_map, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
::decode(version, bl);
::decode(library_map, bl);
}

View File

@ -61,6 +61,8 @@ struct LogEntry {
LogEntryKey key() const { return LogEntryKey(who, stamp, seq); }
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
__u16 t = type;
::encode(who, bl);
::encode(stamp, bl);
@ -69,6 +71,8 @@ struct LogEntry {
::encode(msg, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
__u16 t;
::decode(who, bl);
::decode(stamp, bl);
@ -100,10 +104,14 @@ struct LogSummary {
}
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
::encode(version, bl);
::encode(tail, bl);
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
::decode(version, bl);
::decode(tail, bl);
}

View File

@ -157,6 +157,8 @@ bool AuthMonitor::update_from_paxos()
if (v) {
dout(7) << "update_from_paxos startup: loading summary e" << v << dendl;
bufferlist::iterator p = latest.begin();
__u8 v;
::decode(v, p);
::decode(max_global_id, p);
::decode(mon->key_server, p);
}
@ -169,6 +171,8 @@ bool AuthMonitor::update_from_paxos()
assert(success);
bufferlist::iterator p = bl.begin();
__u8 v;
::decode(v, p);
while (!p.end()) {
Incremental inc;
::decode(inc, p);
@ -199,6 +203,8 @@ bool AuthMonitor::update_from_paxos()
<< " max_global_id=" << max_global_id << dendl;
bufferlist bl;
__u8 v = 1;
::encode(v, bl);
::encode(max_global_id, bl);
Mutex::Locker l(mon->key_server.get_lock());
::encode(mon->key_server, bl);
@ -261,6 +267,8 @@ void AuthMonitor::create_pending()
void AuthMonitor::encode_pending(bufferlist &bl)
{
dout(10) << "encode_pending v " << (paxos->get_version() + 1) << dendl;
__u8 v = 1;
::encode(v, bl);
for (vector<Incremental>::iterator p = pending_auth.begin();
p != pending_auth.end();
p++)

View File

@ -45,6 +45,8 @@ public:
bufferlist auth_data;
void encode(bufferlist& bl) const {
__u8 v = 1;
::encode(v, bl);
__u32 _type = (__u32)inc_type;
::encode(_type, bl);
if (_type == GLOBAL_ID) {
@ -55,6 +57,8 @@ public:
}
}
void decode(bufferlist::iterator& bl) {
__u8 v;
::decode(v, bl);
__u32 _type;
::decode(_type, bl);
inc_type = (IncType)_type;

View File

@ -118,6 +118,8 @@ bool ClassMonitor::update_from_paxos()
assert(success);
bufferlist::iterator p = bl.begin();
__u8 v;
::decode(v, p);
ClassLibraryIncremental inc;
::decode(inc, p);
ClassImpl impl;
@ -170,6 +172,8 @@ void ClassMonitor::create_pending()
void ClassMonitor::encode_pending(bufferlist &bl)
{
dout(10) << "encode_pending v " << (paxos->get_version() + 1) << dendl;
__u8 v = 1;
::encode(v, bl);
for (multimap<utime_t,ClassLibraryIncremental>::iterator p = pending_class.begin();
p != pending_class.end();
p++)

View File

@ -120,6 +120,8 @@ bool LogMonitor::update_from_paxos()
assert(success);
bufferlist::iterator p = bl.begin();
__u8 v;
::decode(v, p);
while (!p.end()) {
LogEntry le;
le.decode(p);
@ -179,6 +181,8 @@ void LogMonitor::create_pending()
void LogMonitor::encode_pending(bufferlist &bl)
{
dout(10) << "encode_pending v " << (paxos->get_version() + 1) << dendl;
__u8 v = 1;
::encode(v, bl);
for (multimap<utime_t,LogEntry>::iterator p = pending_log.begin();
p != pending_log.end();
p++)

View File

@ -47,6 +47,8 @@ public:
set<pg_t> pg_remove;
void encode(bufferlist &bl) const {
__u8 v = 1;
::encode(v, bl);
::encode(version, bl);
::encode(pg_stat_updates, bl);
::encode(osd_stat_updates, bl);
@ -56,6 +58,8 @@ public:
::encode(pg_remove, bl);
}
void decode(bufferlist::iterator &bl) {
__u8 v;
::decode(v, bl);
::decode(version, bl);
::decode(pg_stat_updates, bl);
::decode(osd_stat_updates, bl);
@ -183,6 +187,8 @@ public:
nearfull_ratio(CEPH_OSD_NEARFULL_RATIO) {}
void encode(bufferlist &bl) {
__u8 v = 1;
::encode(v, bl);
::encode(version, bl);
::encode(pg_stat, bl);
::encode(osd_stat, bl);
@ -190,6 +196,8 @@ public:
::encode(last_pg_scan, bl);
}
void decode(bufferlist::iterator &bl) {
__u8 v;
::decode(v, bl);
::decode(version, bl);
::decode(pg_stat, bl);
::decode(osd_stat, bl);