]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: add ErasureCodeInterface::get_coding_chunk_count
authorLoic Dachary <loic@dachary.org>
Wed, 6 Aug 2014 14:50:16 +0000 (16:50 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Fri, 29 Aug 2014 17:38:56 +0000 (19:38 +0200)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/erasure-code/ErasureCode.h
src/erasure-code/ErasureCodeInterface.h
src/test/erasure-code/ceph_erasure_code.cc

index dec2bd9b1a8eac4c5da0d35a0ee55121a53ed909..7aaea951713b6b753cd2bd4d4fc5ea838be1cd06 100644 (file)
@@ -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<int> &want_to_read,
                                   const set<int> &available_chunks,
                                   set<int> *minimum);
index f7b2bdc258fcd9bb1155cb82794056c22e45431a..56b5265b9835bd62dfbb1416209900e13c2e9004 100644 (file)
@@ -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
index c3c7117f78be1150e4b3d089b9bd13611597f57a..ed48205e8eff766e87ad9db99127ca227c5cae70 100644 (file)
@@ -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<unsigned int>(),
      "display get_chunk_size(<object 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<vector<string> >(),
      "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: