From: Sage Weil Date: Mon, 29 Oct 2012 18:03:46 +0000 (-0700) Subject: osd: make pool_snap_info_t encoding backward compatible X-Git-Tag: v0.54~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b9eccdf8ba100c847b3ae837e3ef247db991c49d;p=ceph.git osd: make pool_snap_info_t encoding backward compatible Way back in fc869dee1e8a1c90c93cb7e678563772fb1c51fb (v0.42) when we redid the osd type encoding we forgot to make this conditionally encode the old format for old clients. In particular, this means that kernel clients will fail to decode the osdmap if there is a rados pool with a pool-level snapshot defined. Fixes: #3290 Signed-off-by: Sage Weil --- diff --git a/src/include/encoding.h b/src/include/encoding.h index 0b15dcd3361..db5d19658cf 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -569,6 +569,14 @@ inline void encode_nohead(const std::map& m, bufferlist& bl) } } template +inline void encode_nohead(const std::map& m, bufferlist& bl, uint64_t features) +{ + for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { + encode(p->first, bl, features); + encode(p->second, bl, features); + } +} +template inline void decode_nohead(int n, std::map& m, bufferlist::iterator& p) { m.clear(); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 5597c024982..4abcdb434d4 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -443,8 +443,16 @@ void pool_snap_info_t::dump(Formatter *f) const f->dump_string("name", name); } -void pool_snap_info_t::encode(bufferlist& bl) const +void pool_snap_info_t::encode(bufferlist& bl, uint64_t features) const { + if ((features & CEPH_FEATURE_PGPOOL3) == 0) { + __u8 struct_v = 1; + ::encode(struct_v, bl); + ::encode(snapid, bl); + ::encode(stamp, bl); + ::encode(name, bl); + return; + } ENCODE_START(2, 2, bl); ::encode(snapid, bl); ::encode(stamp, bl); @@ -659,7 +667,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const ::encode(auid, bl); - ::encode_nohead(snaps, bl); + ::encode_nohead(snaps, bl, features); removed_snaps.encode_nohead(bl); return; } @@ -679,7 +687,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const ::encode(last_change, bl); ::encode(snap_seq, bl); ::encode(snap_epoch, bl); - ::encode(snaps, bl); + ::encode(snaps, bl, features); ::encode(removed_snaps, bl); ::encode(auid, bl); ::encode(flags, bl); @@ -700,7 +708,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const ::encode(last_change, bl); ::encode(snap_seq, bl); ::encode(snap_epoch, bl); - ::encode(snaps, bl); + ::encode(snaps, bl, features); ::encode(removed_snaps, bl); ::encode(auid, bl); ::encode(flags, bl); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 503a514406e..7c1aad1d77e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -589,11 +589,11 @@ struct pool_snap_info_t { string name; 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& o); }; -WRITE_CLASS_ENCODER(pool_snap_info_t) +WRITE_CLASS_ENCODER_FEATURES(pool_snap_info_t) inline ostream& operator<<(ostream& out, const pool_snap_info_t& si) { return out << si.snapid << '(' << si.name << ' ' << si.stamp << ')'; diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 6633466953f..9993aa3b550 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -36,7 +36,7 @@ TYPE(pg_t) TYPE(coll_t) TYPE(osd_stat_t) TYPE(OSDSuperblock) -TYPE(pool_snap_info_t) +TYPE_FEATUREFUL(pool_snap_info_t) TYPE_FEATUREFUL(pg_pool_t) TYPE(object_stat_sum_t) TYPE(object_stat_collection_t)