]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: erasure code plugin loader helper
authorLoic Dachary <loic@dachary.org>
Sun, 2 Feb 2014 08:59:52 +0000 (09:59 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 4 Feb 2014 07:06:26 +0000 (08:06 +0100)
The get_erasure_code helper loads the erasure code plugin found in the
erasure-code-plugin string of the properties argument. It is meant to be
used to query the plugin to determine the desired size of a pool, the
more suitable ruleset to use etc.

Reviewed-By: Christophe Courtaut <christophe.courtaut@gmail.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 0a733684d2d7e86be61816c19818abe5dca54316..54e2285f5c8e3d5fe9a73f4ce709f3c52253d1b8 100644 (file)
@@ -2742,6 +2742,23 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m)
                             properties, pg_pool_t::TYPE_REPLICATED, ss);
 }
 
+int OSDMonitor::get_erasure_code(const map<string,string> &properties,
+                                ErasureCodeInterfaceRef *erasure_code,
+                                stringstream &ss)
+{
+  map<string,string>::const_iterator plugin =
+    properties.find("erasure-code-plugin");
+  if (plugin == properties.end()) {
+    ss << "cannot determine the erasure code plugin"
+       << " because erasure-code-plugin is not in the properties "
+       << properties;
+    return -EINVAL;
+  }
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  return instance.factory(plugin->second, properties, erasure_code);
+}
+
+
 int OSDMonitor::prepare_pool_properties(const unsigned pool_type,
                                        const vector<string> &properties,
                                        map<string,string> *properties_map,
index 83ca34dab076d053835327dc37ef0edb9a7903aa..a490d37e5c5a3e75edd85ee7d7d389856235d2ae 100644 (file)
@@ -37,6 +37,8 @@ class Monitor;
 #include "messages/MOSDFailure.h"
 #include "messages/MPoolOp.h"
 
+#include "osd/ErasureCodeInterface.h"
+
 #define OSD_METADATA_PREFIX "osd_metadata"
 
 /// information about a particular peer's failure reports for one osd
@@ -236,6 +238,9 @@ private:
   bool prepare_pool_op (MPoolOp *m);
   bool prepare_pool_op_create (MPoolOp *m);
   bool prepare_pool_op_delete(MPoolOp *m);
+  int get_erasure_code(const map<string,string> &properties,
+                      ErasureCodeInterfaceRef *erasure_code,
+                      stringstream &ss);
   int prepare_pool_properties(const unsigned pool_type,
                              const vector<string> &properties,
                              map<string,string> *properties_map,