]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: fix BlaumRoth sanity check on w 2442/head
authorLoic Dachary <loic-201408@dachary.org>
Tue, 9 Sep 2014 19:43:59 +0000 (21:43 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Tue, 9 Sep 2014 19:56:46 +0000 (21:56 +0200)
For the BlaumRoth technique, w+1 must be a prime. This sanity check is
present in the sample code from the jerasure library but was not
implemented in the jerasure plugin.

The default value for w is also changed to match this constraint. The
unit tests is changed to always use the default w instead of forcing it
to w.

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

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
src/erasure-code/jerasure/ErasureCodeJerasure.cc
src/erasure-code/jerasure/ErasureCodeJerasure.h
src/test/erasure-code/TestErasureCodeJerasure.cc

index bc845833f319526d36c3469992146997ecc8327d..d48e0dbe44e3015aa8ea2be3466d979a4014b095 100644 (file)
@@ -4,6 +4,7 @@
  * Ceph distributed storage system
  *
  * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
  *
  * Author: Loic Dachary <loic@dachary.org>
  *
@@ -451,6 +452,17 @@ void ErasureCodeJerasureLiberation::prepare()
 // 
 // ErasureCodeJerasureBlaumRoth
 //
+bool ErasureCodeJerasureBlaumRoth::check_w(ostream *ss) const
+{
+  if (w <= 2 || !is_prime(w+1)) {
+    *ss <<  "w=" << w << " must be greater than two and "
+       << "w+1 must be prime" << std::endl;
+    return false;
+  } else {
+    return true;
+  }
+}
+
 void ErasureCodeJerasureBlaumRoth::prepare()
 {
   bitmatrix = blaum_roth_coding_bitmatrix(k, w);
index 8034b99385f0385f632098fdb3c9f517bd630a73..4a3b337a11b98a8ab4acd7c3b67ad0063c762ed2 100644 (file)
@@ -4,6 +4,7 @@
  * Ceph distributed storage system
  *
  * Copyright (C) 2013, 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
  *
  * Author: Loic Dachary <loic@dachary.org>
  *
@@ -234,8 +235,11 @@ class ErasureCodeJerasureBlaumRoth : public ErasureCodeJerasureLiberation {
 public:
   ErasureCodeJerasureBlaumRoth() :
     ErasureCodeJerasureLiberation("blaum_roth")
-  {}
+  {
+    DEFAULT_W = 6;
+  }
 
+  virtual bool check_w(ostream *ss) const;
   virtual void prepare();
 };
 
index b7f35ac6496d4bc6b9a2e93e775b6e55870786d5..37629519c37adfbd8438db3493fd1d803cd19452 100644 (file)
@@ -4,6 +4,7 @@
  * Ceph distributed storage system
  *
  * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
  *
  * Author: Loic Dachary <loic@dachary.org>
  *
@@ -50,7 +51,6 @@ TYPED_TEST(ErasureCodeTest, encode_decode)
     map<std::string,std::string> parameters;
     parameters["k"] = "2";
     parameters["m"] = "2";
-    parameters["w"] = "7";
     parameters["packetsize"] = "8";
     parameters["jerasure-per-chunk-alignment"] =
       per_chunk_alignments[per_chunk_alignment];