]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: ErasureCodeIsa update default values to string
authorLoic Dachary <ldachary@redhat.com>
Sun, 17 May 2015 15:58:36 +0000 (17:58 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sat, 30 May 2015 22:01:34 +0000 (00:01 +0200)
Update the ErasureCodeIsa::init function to use string default values
and update the profile accordingly.

Also fix a bug by which the plugin would incorrectly report using the
default technique when the reed_sol_van or cauchy techniques are the
only legitimate values.

http://tracker.ceph.com/issues/9589 Fixes: #9589

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/erasure-code/isa/ErasureCodeIsa.cc
src/erasure-code/isa/ErasureCodeIsa.h
src/erasure-code/isa/ErasureCodePluginIsa.cc

index 697062e9a9192a68a71b22e8de9ad767d74c3bc4..5f94b661e47dad7c1e01368d610118cc0bd543b8 100644 (file)
@@ -41,6 +41,9 @@ _prefix(std::ostream* _dout)
 }
 // -----------------------------------------------------------------------------
 
+const std::string ErasureCodeIsaDefault::DEFAULT_K("7");
+const std::string ErasureCodeIsaDefault::DEFAULT_M("3");
+
 int
 ErasureCodeIsa::create_ruleset(const string &name,
                                CrushWrapper &crush,
@@ -67,14 +70,12 @@ int
 ErasureCodeIsa::init(ErasureCodeProfile &profile, ostream *ss)
 {
   int err = 0;
-  dout(10) << "technique=" << technique << dendl;
-  map<string, string>::const_iterator parameter;
-  parameter = profile.find("ruleset-root");
-  if (parameter != profile.end())
-    ruleset_root = parameter->second;
-  parameter = profile.find("ruleset-failure-domain");
-  if (parameter != profile.end())
-    ruleset_failure_domain = parameter->second;
+  err |= to_string("ruleset-root", profile,
+                  &ruleset_root,
+                  DEFAULT_RULESET_ROOT, ss);
+  err |= to_string("ruleset-failure-domain", profile,
+                  &ruleset_failure_domain,
+                  DEFAULT_RULESET_FAILURE_DOMAIN, ss);
   err |= parse(profile, ss);
   if (err)
     return err;
index 764e55a471a773607d1f323957e1285739acc96a..e7c6525b3211220cc54fd65727bc0cc4895bee49 100644 (file)
@@ -33,6 +33,9 @@
 #include <list>
 // -----------------------------------------------------------------------------
 
+#define DEFAULT_RULESET_ROOT "default"
+#define DEFAULT_RULESET_FAILURE_DOMAIN "host"
+
 class ErasureCodeIsa : public ErasureCode {
 public:
 
@@ -56,8 +59,8 @@ public:
   w(0),
   tcache(_tcache),
   technique(_technique),
-  ruleset_root("default"),
-  ruleset_failure_domain("host")
+  ruleset_root(DEFAULT_RULESET_ROOT),
+  ruleset_failure_domain(DEFAULT_RULESET_FAILURE_DOMAIN)
   {
   }
 
@@ -120,8 +123,8 @@ private:
 
 public:
 
-  static const int DEFAULT_K = 7;
-  static const int DEFAULT_M = 3;
+  static const std::string DEFAULT_K;
+  static const std::string DEFAULT_M;
 
   unsigned char* encode_coeff; // encoding coefficient
   unsigned char* encode_tbls; // encoding table
index 86aff3ae0e48f541e243aab831c2372967aca26d..3c4b140823dbb203875eb37a93780c0c35a493b6 100644 (file)
@@ -40,9 +40,10 @@ public:
                       ostream *ss)
   {
     ErasureCodeIsa *interface;
-    std::string t = "reed_sol_van";
-    if (profile.find("technique") != profile.end())
-      t = profile.find("technique")->second;
+    std::string t;
+    if (profile.find("technique") == profile.end())
+      profile["technique"] = "reed_sol_van";
+    t = profile.find("technique")->second;
     if ((t == "reed_sol_van")) {
       interface = new ErasureCodeIsaDefault(tcache,
                                             ErasureCodeIsaDefault::kVandermonde);