]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: override the default only if the plugin match
authorLoic Dachary <loic-201408@dachary.org>
Sun, 24 Aug 2014 18:57:16 +0000 (20:57 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Fri, 29 Aug 2014 17:38:57 +0000 (19:38 +0200)
When setting a new erasure coded profile, the key/value of the default
profile are re-used so that ruleset-failure-domain=osd can be overridden
like so:

        ceph osd erasure-code-profile set ruleset-failure-domain=osd

This is however not appropriate if the plugin is different from the
defaut plugin (for instance LRC instead of jerasure) because the
parameters are not the same.

If the plugin is changed, the default profile is not reused.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
src/mon/OSDMonitor.cc

index 1923bfc5645c264441cebe56eddecbb29ffa1e8b..2a3de20ffa45908836f259922d6faa48efc2b750 100644 (file)
@@ -3299,23 +3299,32 @@ int OSDMonitor::parse_erasure_code_profile(const vector<string> &erasure_code_pr
                      erasure_code_profile_map);
   if (r)
     return r;
-  (*erasure_code_profile_map)["directory"] =
-    g_conf->osd_pool_default_erasure_code_directory;
-
+  assert((*erasure_code_profile_map).count("plugin"));
+  string default_plugin = (*erasure_code_profile_map)["plugin"];
+  map<string,string> user_map;
   for (vector<string>::const_iterator i = erasure_code_profile.begin();
        i != erasure_code_profile.end();
        ++i) {
     size_t equal = i->find('=');
-    if (equal == string::npos)
+    if (equal == string::npos) {
+      user_map[*i] = string();
       (*erasure_code_profile_map)[*i] = string();
-    else {
+    else {
       const string key = i->substr(0, equal);
       equal++;
       const string value = i->substr(equal);
+      user_map[key] = value;
       (*erasure_code_profile_map)[key] = value;
     }
   }
 
+  if (user_map.count("plugin") && user_map["plugin"] != default_plugin)
+    (*erasure_code_profile_map) = user_map;
+
+  if ((*erasure_code_profile_map).count("directory") == 0)
+    (*erasure_code_profile_map)["directory"] =
+      g_conf->osd_pool_default_erasure_code_directory;
+
   return 0;
 }