osd: make pool_stat_t encoding backward compatible with v0.41 and older

In particular, this is the encoding that is used in precise.

Fixes: #3212
Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-12-07 14:09:14 -08:00
parent 81e567c90d
commit 25ea06969f
5 changed files with 15 additions and 6 deletions

View File

@ -159,7 +159,7 @@ WRITE_INTTYPE_ENCODER(int16_t, le16)
// string
inline void encode(const std::string& s, bufferlist& bl)
inline void encode(const std::string& s, bufferlist& bl, uint64_t features=0)
{
__u32 len = s.length();
encode(len, bl);

View File

@ -42,7 +42,7 @@ public:
void encode_payload(uint64_t features) {
paxos_encode();
::encode(fsid, payload);
::encode(pool_stats, payload);
::encode(pool_stats, payload, features);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();

View File

@ -1152,8 +1152,17 @@ void pool_stat_t::dump(Formatter *f) const
f->dump_unsigned("ondisk_log_size", ondisk_log_size);
}
void pool_stat_t::encode(bufferlist &bl) const
void pool_stat_t::encode(bufferlist &bl, uint64_t features) const
{
if ((features & CEPH_FEATURE_OSDENC) == 0) {
__u8 v = 4;
::encode(v, bl);
::encode(stats, bl);
::encode(log_size, bl);
::encode(ondisk_log_size, bl);
return;
}
ENCODE_START(5, 5, bl);
::encode(stats, bl);
::encode(log_size, bl);

View File

@ -941,11 +941,11 @@ struct pool_stat_t {
}
void dump(Formatter *f) const;
void encode(bufferlist &bl) const;
void encode(bufferlist &bl, uint64_t features) const;
void decode(bufferlist::iterator &bl);
static void generate_test_instances(list<pool_stat_t*>& o);
};
WRITE_CLASS_ENCODER(pool_stat_t)
WRITE_CLASS_ENCODER_FEATURES(pool_stat_t)
/**

View File

@ -41,7 +41,7 @@ TYPE_FEATUREFUL(pg_pool_t)
TYPE(object_stat_sum_t)
TYPE(object_stat_collection_t)
TYPE(pg_stat_t)
TYPE(pool_stat_t)
TYPE_FEATUREFUL(pool_stat_t)
TYPE(pg_history_t)
TYPE(pg_info_t)
TYPE(pg_interval_t)