From 6eaeb56718c0f53c2710ac25ac658d54beaa739c Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 17 May 2015 17:58:36 +0200 Subject: [PATCH] erasure-code: ErasureCodeIsa update default values to string 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 --- src/erasure-code/isa/ErasureCodeIsa.cc | 17 +++++++++-------- src/erasure-code/isa/ErasureCodeIsa.h | 11 +++++++---- src/erasure-code/isa/ErasureCodePluginIsa.cc | 7 ++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/erasure-code/isa/ErasureCodeIsa.cc b/src/erasure-code/isa/ErasureCodeIsa.cc index 697062e9a9192..5f94b661e47da 100644 --- a/src/erasure-code/isa/ErasureCodeIsa.cc +++ b/src/erasure-code/isa/ErasureCodeIsa.cc @@ -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::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; diff --git a/src/erasure-code/isa/ErasureCodeIsa.h b/src/erasure-code/isa/ErasureCodeIsa.h index 764e55a471a77..e7c6525b32112 100644 --- a/src/erasure-code/isa/ErasureCodeIsa.h +++ b/src/erasure-code/isa/ErasureCodeIsa.h @@ -33,6 +33,9 @@ #include // ----------------------------------------------------------------------------- +#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 diff --git a/src/erasure-code/isa/ErasureCodePluginIsa.cc b/src/erasure-code/isa/ErasureCodePluginIsa.cc index 86aff3ae0e48f..3c4b140823dbb 100644 --- a/src/erasure-code/isa/ErasureCodePluginIsa.cc +++ b/src/erasure-code/isa/ErasureCodePluginIsa.cc @@ -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); -- 2.39.5