]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ErasureCodeJerasure: define techniques CauchyOrig and CauchyGood
authorLoic Dachary <loic@dachary.org>
Mon, 9 Sep 2013 23:40:02 +0000 (01:40 +0200)
committerLoic Dachary <loic@dachary.org>
Tue, 10 Sep 2013 14:46:22 +0000 (16:46 +0200)
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 <loic@dachary.org>
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h
src/test/osd/TestErasureCodeJerasure.cc

index f6bd18589d14a760de0d2b741e58889309f7360c..6283915b65a108c2ca32175d1813ec1d337c893c 100644 (file)
@@ -232,3 +232,55 @@ void ErasureCodeJerasureReedSolomonRAID6::parse(const map<std::string,std::strin
 void ErasureCodeJerasureReedSolomonRAID6::prepare() {
   matrix = reed_sol_r6_coding_matrix(k, w);
 }
+
+// 
+// ErasureCodeJerasureCauchy
+//
+void ErasureCodeJerasureCauchy::jerasure_encode(char **data,
+                                                    char **coding,
+                                                    int blocksize) {
+  jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
+}
+
+int ErasureCodeJerasureCauchy::jerasure_decode(int *erasures,
+                                                    char **data,
+                                                    char **coding,
+                                                    int blocksize) {
+  return jerasure_schedule_decode_lazy(k, m, w, bitmatrix, erasures, data, coding, blocksize, packetsize, 1);
+}
+
+unsigned ErasureCodeJerasureCauchy::pad_in_length(unsigned in_length) {
+  while (in_length%(k*w*packetsize*sizeof(int)) != 0) 
+    in_length++;
+  return in_length;
+}
+
+void ErasureCodeJerasureCauchy::parse(const map<std::string,std::string> &parameters) {
+  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);
+}
index 8ef608d484c4a0347d360ca06c685df0247fd3c2..5484b5e2a229626e66234751e45b8c8974012658 100644 (file)
@@ -119,4 +119,56 @@ public:
   virtual void parse(const map<std::string,std::string> &parameters);
   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<std::string,std::string> &parameters);
+  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
index b17c7b75dba8419ef62251a22b648584f64b7ff4..f35c01f125d8677977c6923bea4d81178e0c60d8 100644 (file)
@@ -28,6 +28,8 @@ class ErasureCodeTest : public ::testing::Test {
 typedef ::testing::Types<
   ErasureCodeJerasureReedSolomonVandermonde,
   ErasureCodeJerasureReedSolomonRAID6,
+  ErasureCodeJerasureCauchyOrig,
+  ErasureCodeJerasureCauchyGood,
 > JerasureTypes;
 TYPED_TEST_CASE(ErasureCodeTest, JerasureTypes);