]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: ErasureCodeInterface::get_chunk_mapping()
authorLoic Dachary <loic@dachary.org>
Tue, 3 Jun 2014 15:45:47 +0000 (17:45 +0200)
committerLoic Dachary <loic@dachary.org>
Thu, 14 Aug 2014 23:07:21 +0000 (01:07 +0200)
Add support for erasure code plugins that do not sequentially map the
chunks encoded to the corresponding index. This is mostly transparent to
the caller, except when it comes to retrieving the data chunks when
reading. For this purpose there needs to be a remapping function so the
caller has a way to figure out which chunks actually contain the data
and reorder them.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/erasure-code/ErasureCode.cc
src/erasure-code/ErasureCode.h
src/erasure-code/ErasureCodeInterface.h
src/test/erasure-code/ErasureCodeExample.h

index 498a06b061779b14bca0ea59505fe1676ff87862..0d3f62f6354d941401c0a99c09d2f4e526fdfe91 100644 (file)
@@ -149,6 +149,10 @@ int ErasureCode::parse(const map<std::string,std::string> &parameters,
   return 0;
 }
 
+const vector<int> &ErasureCode::get_chunk_mapping() const {
+  return chunk_mapping;
+}
+
 int ErasureCode::to_int(const std::string &name,
                        const map<std::string,std::string> &parameters,
                        int *value,
index b70e7f87d7f8a148bd58b7c2b21296013b76e385..637a009d78c2a19bffc3ea9732041899f2a2a8c9 100644 (file)
 
  */ 
 
+#include <vector>
+
 #include "ErasureCodeInterface.h"
 
 namespace ceph {
 
   class ErasureCode : public ErasureCodeInterface {
   public:
+    vector<int> chunk_mapping;
+
     virtual ~ErasureCode() {}
 
     virtual int minimum_to_decode(const set<int> &want_to_read,
@@ -58,6 +62,8 @@ namespace ceph {
     virtual int parse(const map<std::string,std::string> &parameters,
                      ostream *ss);
 
+    virtual const vector<int> &get_chunk_mapping() const;
+
     static int to_int(const std::string &name,
                      const map<std::string,std::string> &parameters,
                      int *value,
index 499cfc96ddc6c9e3d9b3a7640c562deb0292a3bd..f7b2bdc258fcd9bb1155cb82794056c22e45431a 100644 (file)
 
 #include <map>
 #include <set>
+#include <vector>
 #include "include/memory.h"
 #include "include/buffer.h"
 
@@ -347,6 +348,41 @@ namespace ceph {
                               const map<int, bufferlist> &chunks,
                               map<int, bufferlist> *decoded) = 0;
 
+    /**
+     * Return the ordered list of chunks or an empty vector
+     * if no remapping is necessary.
+     *
+     * By default encoding an object with K=2,M=1 will create three
+     * chunks, the first two are data and the last one coding. For
+     * a 10MB object, it would be:
+     *
+     *   chunk 0 for the first 5MB
+     *   chunk 1 for the last 5MB
+     *   chunk 2 for the 5MB coding chunk
+     *
+     * The plugin may, however, decide to remap them in a different
+     * order, such as:
+     *
+     *   chunk 0 for the last 5MB
+     *   chunk 1 for the 5MB coding chunk
+     *   chunk 2 for the first 5MB
+     *
+     * The vector<int> remaps the chunks so that the first chunks are
+     * data, in sequential order, and the last chunks contain parity
+     * in the same order as they were output by the encoding function.
+     *
+     * In the example above the mapping would be:
+     *
+     *   [ 1, 2, 0 ]
+     *
+     * The returned vector<int> only contains information for chunks
+     * that need remapping. If no remapping is necessary, the
+     * vector<int> is empty.
+     *
+     * @return vector<int> list of indices of chunks to be remapped
+     */
+    virtual const vector<int> &get_chunk_mapping() const = 0;
+
     /**
      * Decode the first **get_data_chunk_count()** **chunks** and
      * concatenate them them into **decoded**.
index 2861b648c1ed79752a726b0df611ea6837f015c4..dce35d18e557f1a218e91b561a572933dad93714 100644 (file)
@@ -193,6 +193,11 @@ public:
     return 0;
   }
 
+  virtual const vector<int> &get_chunk_mapping() const {
+    static vector<int> mapping;
+    return mapping;
+  }
+
 };
 
 #endif