]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: create the erasure-code ruleset in OSDMap::build_simple
authorLoic Dachary <loic@dachary.org>
Sun, 16 Mar 2014 15:49:51 +0000 (16:49 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 17 Mar 2014 23:23:42 +0000 (00:23 +0100)
Using the "default" profile, add the matching erasure-code ruleset.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/osd/OSDMap.cc
src/test/cli/osdmaptool/clobber.t

index 4a836168012ae01e5625d1e4e81088d6dd1d77e9..8d06c07a6b69b13e34f7c4dc0a9a4d71ec8448f3 100644 (file)
@@ -20,7 +20,8 @@
 #include "common/config.h"
 #include "common/Formatter.h"
 #include "include/ceph_features.h"
-
+#include "include/str_map.h"
+#include "erasure-code/ErasureCodePlugin.h"
 #include "common/code_environment.h"
 
 #define dout_subsys ceph_subsys_osd
@@ -2554,6 +2555,26 @@ int OSDMap::build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
   erasure_code_profile_map["directory"] =
     cct->_conf->osd_pool_default_erasure_code_directory;
   set_erasure_code_profile("default", erasure_code_profile_map);
+
+  map<string,string>::const_iterator plugin =
+    erasure_code_profile_map.find("plugin");
+  if (plugin == erasure_code_profile_map.end()) {
+    ss << "cannot determine the erasure code plugin"
+       << " because there is no 'plugin' entry in the erasure_code_profile "
+       << erasure_code_profile_map;
+    return -EINVAL;
+  }
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  ErasureCodeInterfaceRef erasure_code;
+  r = instance.factory(plugin->second, erasure_code_profile_map,
+                      &erasure_code, ss);
+  if (r)
+    return r;
+
+  r = erasure_code->create_ruleset("erasure-code", *crush, &ss);
+  if (r < 0)
+    return r;
+
   return r;
 }
 
index 37399fd297f7c443b17351347323f2da1292a8e1..8fd3ff6167c91253b505f0c1186037639263a529 100644 (file)
@@ -1,3 +1,4 @@
+  $ export CEPH_ARGS="--osd-pool-default-erasure-code-directory=.libs"
   $ osdmaptool --createsimple 3 myosdmap
   osdmaptool: osdmap file 'myosdmap'
   osdmaptool: writing epoch 1 to myosdmap