| 94 | */ |
| 95 | template <> |
| 96 | std::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. |
no test coverage detected