]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: implement ErasureCode::sanity_check_k
authorLoic Dachary <ldachary@redhat.com>
Sun, 17 May 2015 22:16:04 +0000 (00:16 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sat, 6 Jun 2015 07:43:49 +0000 (09:43 +0200)
Implement the ErasureCode::sanity_check_k helper for plugins
that need to verify k >= 2.

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

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/erasure-code/ErasureCode.cc
src/erasure-code/ErasureCode.h

index 570677d19cc3a501e196d505194e5f0c0e52a7d3..e7a10aec4675b2ab40cf1859474a4849bd485d89 100644 (file)
 
 const unsigned ErasureCode::SIMD_ALIGN = 32;
 
+int ErasureCode::sanity_check_k(int k, ostream *ss)
+{
+  if (k < 2) {
+    *ss << "k=" << k << " must be >= 2" << std::endl;
+    return -EINVAL;
+  } else {
+    return 0;
+  }
+}
+
 int ErasureCode::chunk_index(unsigned int i) const
 {
   return chunk_mapping.size() > i ? chunk_mapping[i] : i;
index ee41935b55fb6662d25f10651c2b8970d45c38a4..294f538e5de4a5966b7dcdaea1c334307388c2c7 100644 (file)
@@ -46,6 +46,8 @@ namespace ceph {
       return _profile;
     }
 
+    int sanity_check_k(int k, ostream *ss);
+
     virtual unsigned int get_coding_chunk_count() const {
       return get_chunk_count() - get_data_chunk_count();
     }