]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add OSDMap::erasure_code_profile
authorLoic Dachary <loic@dachary.org>
Sun, 16 Mar 2014 11:40:24 +0000 (12:40 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 17 Mar 2014 15:48:30 +0000 (16:48 +0100)
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 <loic@dachary.org>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 9dc7c5769832175f739f35c0bd0e92b011baceb5..e129e2b34fbc0309b784974526298c165a4e3922 100644 (file)
@@ -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<string>::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<Incremental*>& o)
@@ -1194,6 +1212,19 @@ int OSDMap::apply_incremental(const Incremental &inc)
     set_primary_affinity(i->first, i->second);
   }
 
+  // erasure_code_profiles
+  for (map<string,map<string,string> >::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<string>::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<int32_t,uint8_t>::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<string,map<string,string> > &profiles,
+                                       Formatter *f)
+{
+  f->open_object_section("erasure_code_profiles");
+  for (map<string,map<string,string> >::const_iterator i = profiles.begin();
+       i != profiles.end();
+       i++) {
+    f->open_object_section(i->first.c_str());
+    for (map<string,string>::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<OSDMap*>& o)
index 0e0e2c39778caded24c2bbb50914c55f52da9c58..5be72b53f4ace77ef54baec5fbeed6c1210de301 100644 (file)
@@ -132,6 +132,8 @@ public:
     map<int64_t,pg_pool_t> new_pools;
     map<int64_t,string> new_pool_names;
     set<int64_t> old_pools;
+    map<string,map<string,string> > new_erasure_code_profiles;
+    vector<string> old_erasure_code_profiles;
     map<int32_t,entity_addr_t> new_up_client;
     map<int32_t,entity_addr_t> new_up_cluster;
     map<int32_t,uint8_t> new_state;             // XORed onto previous state.
@@ -216,6 +218,7 @@ private:
 
   map<int64_t,pg_pool_t> pools;
   map<int64_t,string> pool_name;
+  map<string,map<string,string> > erasure_code_profiles;
   map<string,int64_t> name_pool;
 
   ceph::shared_ptr< vector<uuid_d> > 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<string,map<string,string> > &profiles,
+                                        Formatter *f);
   void dump_json(ostream& out) const;
   void dump(Formatter *f) const;
   static void generate_test_instances(list<OSDMap*>& o);