From: Loic Dachary Date: Sun, 16 Mar 2014 11:40:24 +0000 (+0100) Subject: osd: add OSDMap::erasure_code_profile X-Git-Tag: v0.79~136^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4f8f265955d54f33c79cde02c1ab2fe69ab1ab0;p=ceph.git osd: add OSDMap::erasure_code_profile A map of key=value properties to be interpreted by the erasure code plugins. For instance profile["default"] = { "k": 2, "m": 1 } Signed-off-by: Loic Dachary --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 9dc7c57698321..e129e2b34fbc0 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -391,7 +391,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const ENCODE_START(7, 7, bl); { - ENCODE_START(2, 1, bl); // client-usable data + ENCODE_START(3, 1, bl); // client-usable data ::encode(fsid, bl); ::encode(epoch, bl); ::encode(modified, bl); @@ -410,6 +410,8 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const ::encode(new_pg_temp, bl); ::encode(new_primary_temp, bl); ::encode(new_primary_affinity, bl); + ::encode(new_erasure_code_profiles, bl); + ::encode(old_erasure_code_profiles, bl); ENCODE_FINISH(bl); // client-usable data } @@ -545,7 +547,7 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl) return; } { - DECODE_START(2, bl); // client-usable data + DECODE_START(3, bl); // client-usable data ::decode(fsid, bl); ::decode(epoch, bl); ::decode(modified, bl); @@ -567,6 +569,13 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl) ::decode(new_primary_affinity, bl); else new_primary_affinity.clear(); + if (struct_v >= 3) { + ::decode(new_erasure_code_profiles, bl); + ::decode(old_erasure_code_profiles, bl); + } else { + new_erasure_code_profiles.clear(); + old_erasure_code_profiles.clear(); + } DECODE_FINISH(bl); // client-usable data } @@ -766,6 +775,15 @@ void OSDMap::Incremental::dump(Formatter *f) const f->close_section(); } f->close_section(); + + OSDMap::dump_erasure_code_profiles(new_erasure_code_profiles, f); + f->open_array_section("old_erasure_code_profiles"); + for (vector::const_iterator p = old_erasure_code_profiles.begin(); + p != old_erasure_code_profiles.end(); + p++) { + f->dump_string("old", p->c_str()); + } + f->close_section(); } void OSDMap::Incremental::generate_test_instances(list& o) @@ -1194,6 +1212,19 @@ int OSDMap::apply_incremental(const Incremental &inc) set_primary_affinity(i->first, i->second); } + // erasure_code_profiles + for (map >::const_iterator i = + inc.new_erasure_code_profiles.begin(); + i != inc.new_erasure_code_profiles.end(); + i++) { + set_erasure_code_profile(i->first, i->second); + } + + for (vector::const_iterator i = inc.old_erasure_code_profiles.begin(); + i != inc.old_erasure_code_profiles.end(); + i++) + erasure_code_profiles.erase(*i); + // up/down for (map::const_iterator i = inc.new_state.begin(); i != inc.new_state.end(); @@ -1728,7 +1759,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const ENCODE_START(7, 7, bl); { - ENCODE_START(2, 1, bl); // client-usable data + ENCODE_START(3, 1, bl); // client-usable data // base ::encode(fsid, bl); ::encode(epoch, bl); @@ -1759,6 +1790,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const bufferlist cbl; crush->encode(cbl); ::encode(cbl, bl); + ::encode(erasure_code_profiles, bl); ENCODE_FINISH(bl); // client-usable data } @@ -1916,7 +1948,7 @@ void OSDMap::decode(bufferlist::iterator& bl) * Since we made it past that hurdle, we can use our normal paths. */ { - DECODE_START(2, bl); // client-usable data + DECODE_START(3, bl); // client-usable data // base ::decode(fsid, bl); ::decode(epoch, bl); @@ -1950,6 +1982,11 @@ void OSDMap::decode(bufferlist::iterator& bl) ::decode(cbl, bl); bufferlist::iterator cblp = cbl.begin(); crush->decode(cblp); + if (struct_v >= 3) { + ::decode(erasure_code_profiles, bl); + } else { + erasure_code_profiles.clear(); + } DECODE_FINISH(bl); // client-usable data } @@ -1984,6 +2021,24 @@ void OSDMap::post_decode() calc_num_osds(); } +void OSDMap::dump_erasure_code_profiles(const map > &profiles, + Formatter *f) +{ + f->open_object_section("erasure_code_profiles"); + for (map >::const_iterator i = profiles.begin(); + i != profiles.end(); + i++) { + f->open_object_section(i->first.c_str()); + for (map::const_iterator j = i->second.begin(); + j != i->second.end(); + j++) { + f->dump_string(j->first.c_str(), j->second.c_str()); + } + f->close_section(); + } + f->close_section(); +} + void OSDMap::dump_json(ostream& out) const { JSONFormatter jsf(true); @@ -2088,6 +2143,8 @@ void OSDMap::dump(Formatter *f) const f->dump_stream(ss.str().c_str()) << p->second; } f->close_section(); + + dump_erasure_code_profiles(erasure_code_profiles, f); } void OSDMap::generate_test_instances(list& o) diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 0e0e2c39778ca..5be72b53f4ace 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -132,6 +132,8 @@ public: map new_pools; map new_pool_names; set old_pools; + map > new_erasure_code_profiles; + vector old_erasure_code_profiles; map new_up_client; map new_up_cluster; map new_state; // XORed onto previous state. @@ -216,6 +218,7 @@ private: map pools; map pool_name; + map > erasure_code_profiles; map name_pool; ceph::shared_ptr< vector > osd_uuid; @@ -781,6 +784,8 @@ public: string get_flag_string() const; static string get_flag_string(unsigned flags); + static void dump_erasure_code_profiles(const map > &profiles, + Formatter *f); void dump_json(ostream& out) const; void dump(Formatter *f) const; static void generate_test_instances(list& o);