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

Method encode_prepare

src/erasure-code/ErasureCode.cc:237–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237IGNORE_DEPRECATED
238[[deprecated]]
239int ErasureCode::encode_prepare(const bufferlist &raw,
240 map<int, bufferlist> &encoded) const
241{
242 unsigned int k = get_data_chunk_count();
243 unsigned int m = get_chunk_count() - k;
244 unsigned blocksize = get_chunk_size(raw.length());
245 unsigned padded_chunks = k - raw.length() / blocksize;
246 bufferlist prepared = raw;
247
248 for (unsigned int i = 0; i < k - padded_chunks; i++) {
249 bufferlist &chunk = encoded[chunk_index(i)];
250 chunk.substr_of(prepared, i * blocksize, blocksize);
251 chunk.rebuild_aligned_size_and_memory(blocksize, SIMD_ALIGN, 1);
252 ceph_assert(chunk.is_contiguous());
253 }
254 if (padded_chunks) {
255 unsigned remainder = raw.length() - (k - padded_chunks) * blocksize;
256 bufferptr buf(buffer::create_aligned(blocksize, SIMD_ALIGN));
257
258 raw.begin((k - padded_chunks) * blocksize).copy(remainder, buf.c_str());
259 buf.zero(remainder, blocksize - remainder);
260 encoded[chunk_index(k-padded_chunks)].push_back(std::move(buf));
261
262 for (unsigned int i = k - padded_chunks + 1; i < k; i++) {
263 bufferptr buf(buffer::create_aligned(blocksize, SIMD_ALIGN));
264 buf.zero();
265 encoded[chunk_index(i)].push_back(std::move(buf));
266 }
267 }
268 for (unsigned int i = k; i < k + m; i++) {
269 bufferlist &chunk = encoded[chunk_index(i)];
270 chunk.push_back(buffer::create_aligned(blocksize, SIMD_ALIGN));
271 }
272
273 return 0;
274}
275END_IGNORE_DEPRECATED
276
277int ErasureCode::encode_prepare(const bufferlist &raw,

Callers

nothing calls this directly

Calls 10

raw_shard_id_tClass · 0.85
is_contiguousMethod · 0.80
lengthMethod · 0.45
substr_ofMethod · 0.45
copyMethod · 0.45
beginMethod · 0.45
c_strMethod · 0.45
zeroMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected