From c2ca011708dd111f196b3a83ce76a768d80e65ef Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 24 Aug 2014 20:52:24 +0200 Subject: [PATCH] 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 --- src/erasure-code/ErasureCode.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/erasure-code/ErasureCode.cc b/src/erasure-code/ErasureCode.cc index e8cab9a6146db..5953f496392bc 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); -- 2.39.5