MCPcopy Create free account
hub / github.com/ceph/ceph / decode_erasures

Method decode_erasures

src/test/erasure-code/ceph_erasure_code_benchmark.cc:211–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211int ErasureCodeBench::decode_erasures(const shard_id_map<bufferlist> &all_chunks,
212 const shard_id_map<bufferlist> &chunks,
213 shard_id_t shard,
214 unsigned want_erasures,
215 ErasureCodeInterfaceRef erasure_code)
216{
217 int code = 0;
218
219 if (want_erasures == 0) {
220 if (verbose)
221 display_chunks(chunks, erasure_code->get_chunk_count());
222 shard_id_set want_to_read;
223 for (shard_id_t chunk; chunk < erasure_code->get_chunk_count(); ++chunk)
224 if (chunks.count(chunk) == 0)
225 want_to_read.insert(chunk);
226
227 shard_id_map<bufferlist> decoded(erasure_code->get_chunk_count());
228 code = erasure_code->decode(want_to_read, chunks, &decoded, 0);
229 if (code)
230 return code;
231 for (shard_id_set::const_iterator chunk = want_to_read.begin();
232 chunk != want_to_read.end();
233 ++chunk) {
234 if (all_chunks.find(*chunk)->second.length() != decoded[*chunk].length()) {
235 cerr << "chunk " << *chunk << " length=" << all_chunks.find(*chunk)->second.length()
236 << " decoded with length=" << decoded[*chunk].length() << std::endl;
237 return -1;
238 }
239 bufferlist tmp = all_chunks.find(*chunk)->second;
240 if (!tmp.contents_equal(decoded[*chunk])) {
241 cerr << "chunk " << *chunk
242 << " content and recovered content are different" << std::endl;
243 return -1;
244 }
245 }
246 return 0;
247 }
248
249 for (; shard < erasure_code->get_chunk_count(); ++shard) {
250 shard_id_map<bufferlist> one_less = chunks;
251 one_less.erase(shard);
252 code = decode_erasures(all_chunks, one_less, shard + 1, want_erasures - 1, erasure_code);
253 if (code)
254 return code;
255 }
256
257 return 0;
258}
259
260int ErasureCodeBench::decode()
261{

Callers

nothing calls this directly

Calls 11

display_chunksFunction · 0.85
contents_equalMethod · 0.80
get_chunk_countMethod · 0.45
countMethod · 0.45
insertMethod · 0.45
decodeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected