diff options
author | Loic Dachary <loic@dachary.org> | 2013-08-29 15:12:32 +0200 |
---|---|---|
committer | Loic Dachary <loic@dachary.org> | 2013-09-10 16:46:22 +0200 |
commit | e9e53912503259326a7877bda31c4360302c2c34 (patch) | |
tree | cba4f7faa03278e70b0031706a570c9d7660796a | |
parent | 63867e941f2be7712391f51fddb9f5a4b76add6d (diff) | |
download | ceph-e9e53912503259326a7877bda31c4360302c2c34.tar.gz |
ErasureCodeJerasure: define technique Liber8tion
technique == "liber8tion"
ErasureCodeInterface (abstract)
|
-> ErasureCodeJerasure (abstract)
|
-> ErasureCodeJerasureLiberation
|
-> ErasureCodeJerasureLiber8tion
| == liber8tion
Derived from Liberation it overloads the parse and prepare methods.
parse : default to K=2 and packetsize = 8.
If any of the following constraints is not satisfied, revert to the
default:
* K <= 8
* packetsize must not be zero
prepare uses liber8tion_coding_bitmatrix
https://github.com/dachary/ceph/tree/wip-5879 refs #5879
Signed-off-by: Loic Dachary <loic@dachary.org>
-rw-r--r-- | src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc | 30 | ||||
-rw-r--r-- | src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h | 15 | ||||
-rw-r--r-- | src/test/osd/TestErasureCodeJerasure.cc | 1 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc index 7fb95177779..25821274081 100644 --- a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc +++ b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc @@ -357,3 +357,33 @@ void ErasureCodeJerasureBlaumRoth::prepare() { bitmatrix = blaum_roth_coding_bitmatrix(k, w); schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix); } + +// +// ErasureCodeJerasureLiber8tion +// +void ErasureCodeJerasureLiber8tion::parse(const map<std::string,std::string> ¶meters) { + k = to_int("erasure-code-k", parameters, DEFAULT_K); + m = DEFAULT_M; + w = DEFAULT_W; + packetsize = to_int("erasure-code-packetsize", parameters, DEFAULT_PACKETSIZE); + + bool error = false; + if (k > w) { + derr << "k=" << k << " must be less than or equal to w=" << w << dendl; + error = true; + } + if (packetsize == 0) { + derr << "packetsize=" << packetsize << " must be set" << dendl; + error = true; + } + if (error) { + derr << "reverting to k=" << DEFAULT_K << ", packetsize=" << DEFAULT_PACKETSIZE << dendl; + k = DEFAULT_K; + packetsize = DEFAULT_PACKETSIZE; + } +} + +void ErasureCodeJerasureLiber8tion::prepare() { + bitmatrix = liber8tion_coding_bitmatrix(k); + schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix); +} diff --git a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h index ddf6c7dcfd1..7728751c383 100644 --- a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h +++ b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h @@ -209,4 +209,19 @@ public: virtual void prepare(); }; + +class ErasureCodeJerasureLiber8tion : public ErasureCodeJerasureLiberation { +public: + static const int DEFAULT_K = 2; + static const int DEFAULT_M = 2; + static const int DEFAULT_W = 8; + + ErasureCodeJerasureLiber8tion() : + ErasureCodeJerasureLiberation("liber8tion") + {} + + virtual void parse(const map<std::string,std::string> ¶meters); + virtual void prepare(); +}; + #endif diff --git a/src/test/osd/TestErasureCodeJerasure.cc b/src/test/osd/TestErasureCodeJerasure.cc index dfbd740e363..266b1735659 100644 --- a/src/test/osd/TestErasureCodeJerasure.cc +++ b/src/test/osd/TestErasureCodeJerasure.cc @@ -32,6 +32,7 @@ typedef ::testing::Types< ErasureCodeJerasureCauchyGood, ErasureCodeJerasureLiberation, ErasureCodeJerasureBlaumRoth, + ErasureCodeJerasureLiber8tion > JerasureTypes; TYPED_TEST_CASE(ErasureCodeTest, JerasureTypes); |