]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: implement ErasureCodeJerasure::create_ruleset
authorLoic Dachary <loic@dachary.org>
Wed, 29 Jan 2014 14:08:01 +0000 (15:08 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 4 Feb 2014 07:06:25 +0000 (08:06 +0100)
It is based on CrushWrapper::add_simple_ruleset, using a "default" root
and "host" failure domain by default. They can be overridden with
erasure-code parameters ( erasure-code-ruleset-root and
erasure-code-ruleset-failure-domain respectively ).

Reviewed-By: Christophe Courtaut <christophe.courtaut@gmail.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h
src/osd/ErasureCodePluginJerasure/Makefile.am

index f1de0e4f8974d3b876c66f27cb6092c1a39cd28a..a39ffbeb3a5c8f7e6faacdb836728e502ba543c6 100644 (file)
@@ -18,6 +18,8 @@
 #include <algorithm>
 #include "common/debug.h"
 #include "ErasureCodeJerasure.h"
+#include "crush/CrushWrapper.h"
+#include "osd/osd_types.h"
 #include "vectorop.h"
 extern "C" {
 #include "jerasure.h"
@@ -36,9 +38,24 @@ static ostream& _prefix(std::ostream* _dout)
   return *_dout << "ErasureCodeJerasure: ";
 }
 
-void ErasureCodeJerasure::init(const map<std::string,std::string> &parameters)
+int ErasureCodeJerasure::create_ruleset(const string &name,
+                                       CrushWrapper &crush,
+                                       ostream *ss) const
+{
+  return crush.add_simple_ruleset(name, ruleset_root, ruleset_failure_domain,
+                                 "indep", pg_pool_t::TYPE_ERASURE, ss);
+}
+
+void ErasureCodeJerasure::init(const map<string,string> &parameters)
 {
   dout(10) << "technique=" << technique << dendl;
+  map<string,string>::const_iterator parameter;
+  parameter = parameters.find("erasure-code-ruleset-root");
+  if (parameter != parameters.end())
+    ruleset_root = parameter->second;
+  parameter = parameters.find("erasure-code-ruleset-failure-domain");
+  if (parameter != parameters.end())
+    ruleset_failure_domain = parameter->second;
   parse(parameters);
   prepare();
 }
index a0db6a02b1c4d9af6bd0593b2f4b148270fc8f3c..042d1b495d8d84fe814eee3c3482262800f82901 100644 (file)
@@ -25,13 +25,21 @@ public:
   int m;
   int w;
   const char *technique;
+  string ruleset_root;
+  string ruleset_failure_domain;
 
   ErasureCodeJerasure(const char *_technique) :
-    technique(_technique)
+    technique(_technique),
+    ruleset_root("default"),
+    ruleset_failure_domain("host")
   {}
 
   virtual ~ErasureCodeJerasure() {}
   
+  virtual int create_ruleset(const string &name,
+                            CrushWrapper &crush,
+                            ostream *ss) const;
+
   virtual unsigned int get_chunk_count() const {
     return k + m;
   }
index 51ef83bf964d522fa0c1c66d24d51b4852ad614c..3f03106c54d251d6b3c05bed6a32f44c7d7191f0 100644 (file)
@@ -19,7 +19,7 @@ noinst_HEADERS += \
 
 libec_jerasure_la_CFLAGS = ${AM_CFLAGS} 
 libec_jerasure_la_CXXFLAGS= ${AM_CXXFLAGS} 
-libec_jerasure_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_jerasure_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0
 if LINUX
 libec_jerasure_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*'