From: Loic Dachary Date: Sun, 24 Aug 2014 18:52:24 +0000 (+0200) Subject: erasure-code: delegate chunk remapping to the plugin X-Git-Tag: v0.86~169^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c2ca011708dd111f196b3a83ce76a768d80e65ef;p=ceph.git erasure-code: delegate chunk remapping to the plugin 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 --- diff --git a/src/erasure-code/ErasureCode.cc b/src/erasure-code/ErasureCode.cc index e8cab9a6146d..5953f496392b 100644 --- a/src/erasure-code/ErasureCode.cc +++ b/src/erasure-code/ErasureCode.cc @@ -4,6 +4,7 @@ * Ceph distributed storage system * * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat * * Author: Loic Dachary * @@ -83,16 +84,12 @@ int ErasureCode::encode(const set &want_to_encode, if (err) return err; unsigned blocksize = get_chunk_size(in.length()); - map 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);