]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: delegate chunk remapping to the plugin
authorLoic Dachary <loic-201408@dachary.org>
Sun, 24 Aug 2014 18:52:24 +0000 (20:52 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Fri, 29 Aug 2014 17:38:57 +0000 (19:38 +0200)
Remapping the chunks after they have been encoded by the plugin is fine
if remapping is transparent to the plugin. However, the goal is to
delegate the remapping of the chunks to the plugin, for LRC in
particular. The chunks are therefore reordered according to the
directions found in the mapping array before they are passed to
decode_chunks.

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

index e8cab9a6146db5b446590f496f9bb39f0ceeff65..5953f496392bc0103ad6ddbae85f610087fd6967 100644 (file)
@@ -4,6 +4,7 @@
  * Ceph distributed storage system
  *
  * Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
  *
  * Author: Loic Dachary <loic@dachary.org>
  *
@@ -83,16 +84,12 @@ int ErasureCode::encode(const set<int> &want_to_encode,
   if (err)
     return err;
   unsigned blocksize = get_chunk_size(in.length());
-  map<int, bufferlist> sorted_encoded;
   for (unsigned int i = 0; i < k + m; i++) {
-    bufferlist &chunk = sorted_encoded[i];
+    int chunk_index = chunk_mapping.size() > 0 ? chunk_mapping[i] : i;
+    bufferlist &chunk = (*encoded)[chunk_index];
     chunk.substr_of(out, i * blocksize, blocksize);
   }
-  encode_chunks(want_to_encode, &sorted_encoded);
-  for (unsigned int i = 0; i < k + m; i++) {
-    int chunk = chunk_mapping.size() > 0 ? chunk_mapping[i] : i;
-    (*encoded)[chunk].claim(sorted_encoded[i]);
-  }
+  encode_chunks(want_to_encode, encoded);
   for (unsigned int i = 0; i < k + m; i++) {
     if (want_to_encode.count(i) == 0)
       encoded->erase(i);