From: Loic Dachary Date: Mon, 9 Sep 2013 23:40:02 +0000 (+0200) Subject: ErasureCodeJerasure: define techniques CauchyOrig and CauchyGood X-Git-Tag: v0.71~129^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=530fb8a51f27363f6ccf4fe5d7f214407e1ca55a;p=ceph.git ErasureCodeJerasure: define techniques CauchyOrig and CauchyGood The technique Cauchy has two variants: ErasureCodeInterface (abstract) | -> ErasureCodeJerasure (abstract) | -> ErasureCodeJerasureCauchy (abstract) | | | -> ErasureCodeJerasureCauchyOrig | | == cauchy_orig | -> ErasureCodeJerasureCauchyGood | | == cauchy_good ErasureCodeJerasureCauchy defines the prepare_schedule method to be used by prepare method, which is the only one overloaded by ErasureCodeJerasureCauchyOrig (calling cauchy_original_coding_matrix) and ErasureCodeJerasureCauchyGood ( calling cauchy_good_general_coding_matrix). The schedule is retained for encoding and the bitmatrix for decoding. parse : default to K=7, M=3, W=8 and packetsize = 8. pad_in_length : pad to a multiple of k*w*packetsize*sizeof(int) jerasure_encode, jerasure_decode map directly to the matching jerasure functions https://github.com/dachary/ceph/tree/wip-5879 refs #5879 Signed-off-by: Loic Dachary --- diff --git a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc index f6bd18589d14a..6283915b65a10 100644 --- a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc +++ b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc @@ -232,3 +232,55 @@ void ErasureCodeJerasureReedSolomonRAID6::parse(const map ¶meters) { + k = to_int("erasure-code-k", parameters, DEFAULT_K); + m = to_int("erasure-code-m", parameters, DEFAULT_M); + w = to_int("erasure-code-w", parameters, DEFAULT_W); + packetsize = to_int("erasure-code-packetsize", parameters, DEFAULT_PACKETSIZE); +} + +void ErasureCodeJerasureCauchy::prepare_schedule(int *matrix) { + bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix); + schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix); +} + +// +// ErasureCodeJerasureCauchyOrig +// +void ErasureCodeJerasureCauchyOrig::prepare() { + int *matrix = cauchy_original_coding_matrix(k, m, w); + prepare_schedule(matrix); + free(matrix); +} + +// +// ErasureCodeJerasureCauchyGood +// +void ErasureCodeJerasureCauchyGood::prepare() { + int *matrix = cauchy_good_general_coding_matrix(k, m, w); + prepare_schedule(matrix); + free(matrix); +} diff --git a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h index 8ef608d484c4a..5484b5e2a2296 100644 --- a/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h +++ b/src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h @@ -119,4 +119,56 @@ public: virtual void parse(const map ¶meters); virtual void prepare(); }; + +class ErasureCodeJerasureCauchy : public ErasureCodeJerasure { +public: + static const int DEFAULT_K = 7; + static const int DEFAULT_M = 3; + static const int DEFAULT_W = 8; + static const int DEFAULT_PACKETSIZE = 8; + int *bitmatrix; + int **schedule; + int packetsize; + + ErasureCodeJerasureCauchy(const char *technique) : + ErasureCodeJerasure(technique), + bitmatrix(0), + schedule(0) + { } + virtual ~ErasureCodeJerasureCauchy() { + if (bitmatrix) + free(bitmatrix); + if (schedule) + free(schedule); + } + + virtual void jerasure_encode(char **data, + char **coding, + int blocksize); + virtual int jerasure_decode(int *erasures, + char **data, + char **coding, + int blocksize); + virtual unsigned pad_in_length(unsigned in_length); + virtual void parse(const map ¶meters); + void prepare_schedule(int *matrix); +}; + +class ErasureCodeJerasureCauchyOrig : public ErasureCodeJerasureCauchy { +public: + ErasureCodeJerasureCauchyOrig() : + ErasureCodeJerasureCauchy("cauchy_orig") + {} + + virtual void prepare(); +}; + +class ErasureCodeJerasureCauchyGood : public ErasureCodeJerasureCauchy { +public: + ErasureCodeJerasureCauchyGood() : + ErasureCodeJerasureCauchy("cauchy_good") + {} + + virtual void prepare(); +}; #endif diff --git a/src/test/osd/TestErasureCodeJerasure.cc b/src/test/osd/TestErasureCodeJerasure.cc index b17c7b75dba84..f35c01f125d86 100644 --- a/src/test/osd/TestErasureCodeJerasure.cc +++ b/src/test/osd/TestErasureCodeJerasure.cc @@ -28,6 +28,8 @@ class ErasureCodeTest : public ::testing::Test { typedef ::testing::Types< ErasureCodeJerasureReedSolomonVandermonde, ErasureCodeJerasureReedSolomonRAID6, + ErasureCodeJerasureCauchyOrig, + ErasureCodeJerasureCauchyGood, > JerasureTypes; TYPED_TEST_CASE(ErasureCodeTest, JerasureTypes);