From: Loic Dachary Date: Wed, 6 Aug 2014 14:50:16 +0000 (+0200) Subject: erasure-code: add ErasureCodeInterface::get_coding_chunk_count X-Git-Tag: v0.86~169^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2e07d954df3bfc0c7a988f54f8b738f8d7ab941;p=ceph.git erasure-code: add ErasureCodeInterface::get_coding_chunk_count Signed-off-by: Loic Dachary --- diff --git a/src/erasure-code/ErasureCode.h b/src/erasure-code/ErasureCode.h index dec2bd9b1a8e..7aaea951713b 100644 --- a/src/erasure-code/ErasureCode.h +++ b/src/erasure-code/ErasureCode.h @@ -34,6 +34,10 @@ namespace ceph { virtual ~ErasureCode() {} + virtual unsigned int get_coding_chunk_count() const { + return get_chunk_count() - get_data_chunk_count(); + } + virtual int minimum_to_decode(const set &want_to_read, const set &available_chunks, set *minimum); diff --git a/src/erasure-code/ErasureCodeInterface.h b/src/erasure-code/ErasureCodeInterface.h index f7b2bdc258fc..56b5265b9835 100644 --- a/src/erasure-code/ErasureCodeInterface.h +++ b/src/erasure-code/ErasureCodeInterface.h @@ -197,6 +197,18 @@ namespace ceph { */ virtual unsigned int get_data_chunk_count() const = 0; + /** + * Return the number of coding chunks created by a call to the + * **encode** method. The coding chunks are used to recover from + * the loss of one or more chunks. If there is one coding chunk, + * it is possible to recover from the loss of exactly one + * chunk. If there are two coding chunks, it is possible to + * recover from the loss of at most two chunks, etc. + * + * @return the number of coding chunks created by encode() + */ + virtual unsigned int get_coding_chunk_count() const = 0; + /** * Return the size (in bytes) of a single chunk created by a call * to the **decode** method. The returned size multiplied by diff --git a/src/test/erasure-code/ceph_erasure_code.cc b/src/test/erasure-code/ceph_erasure_code.cc index c3c7117f78be..ed48205e8eff 100644 --- a/src/test/erasure-code/ceph_erasure_code.cc +++ b/src/test/erasure-code/ceph_erasure_code.cc @@ -49,10 +49,12 @@ int ErasureCodeCommand::setup(int argc, char** argv) { ("all", "implies " "--get_chunk_size 1024 " "--get_data_chunk_count " + "--get_coding_chunk_count " "--get_chunk_count ") ("get_chunk_size", po::value(), "display get_chunk_size()") ("get_data_chunk_count", "display get_data_chunk_count()") + ("get_coding_chunk_count", "display get_coding_chunk_count()") ("get_chunk_count", "display get_chunk_count()") ("parameter,P", po::value >(), "parameters") @@ -133,6 +135,9 @@ int ErasureCodeCommand::run() { if (vm.count("all") || vm.count("get_data_chunk_count")) cout << "get_data_chunk_count\t" << erasure_code->get_data_chunk_count() << endl; + if (vm.count("all") || vm.count("get_coding_chunk_count")) + cout << "get_coding_chunk_count\t" + << erasure_code->get_coding_chunk_count() << endl; if (vm.count("all") || vm.count("get_chunk_count")) cout << "get_chunk_count\t" << erasure_code->get_chunk_count() << endl; @@ -160,6 +165,7 @@ int main(int argc, char** argv) { * --parameter m=2 \ * --get_chunk_size 1024 \ * --get_data_chunk_count \ + * --get_coding_chunk_count \ * --get_chunk_count \ * " * End: