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

Method do_encode

src/erasure-code/consistency/ECEncoder.cc:96–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 */
95template <>
96std::optional<ceph::bufferlist> ECEncoder<stripe_info_o_t>::do_encode(ceph::bufferlist inbl,
97 stripe_info_o_t &sinfo)
98{
99 ECUtil::shard_extent_map_t encoded_data(&sinfo);
100
101 uint64_t stripe_width = sinfo.get_stripe_width();
102 if (inbl.length() % stripe_width != 0) {
103 uint64_t pad = stripe_width - inbl.length() % stripe_width;
104 inbl.append_zero(pad);
105 }
106
107 sinfo.ro_range_to_shard_extent_map(0, inbl.length(), inbl, encoded_data);
108 encoded_data.insert_parity_buffers();
109 int r = encoded_data.encode(ec_impl);
110 if (r < 0) {
111 std::cerr << "Failed to encode: " << cpp_strerror(r) << std::endl;
112 return {};
113 }
114
115 ceph::bufferlist outbl;
116 for (const auto &[shard, _] : encoded_data.get_extent_maps()) {
117 if (shard >= sinfo.get_k()) {
118 encoded_data.get_shard_first_buffer(shard, outbl);
119 }
120 }
121
122 return outbl;
123}
124
125/**
126 * Perform encode on the input buffer and place result in the supplied output buffer.

Callers 1

Calls 15

cpp_strerrorFunction · 0.85
do_encodeFunction · 0.85
insert_parity_buffersMethod · 0.80
copy_allMethod · 0.80
encodeFunction · 0.50
get_stripe_widthMethod · 0.45
lengthMethod · 0.45
append_zeroMethod · 0.45
encodeMethod · 0.45
get_kMethod · 0.45

Tested by

no test coverage detected