| 91 | } |
| 92 | |
| 93 | int ErasureCodeIsa::decode_chunks(const set<int> &want_to_read, |
| 94 | const map<int, bufferlist> &chunks, |
| 95 | map<int, bufferlist> *decoded) |
| 96 | { |
| 97 | unsigned blocksize = (*chunks.begin()).second.length(); |
| 98 | int erasures[k + m + 1]; |
| 99 | int erasures_count = 0; |
| 100 | char *data[k]; |
| 101 | char *coding[m]; |
| 102 | for (int i = 0; i < k + m; i++) { |
| 103 | if (chunks.find(i) == chunks.end()) { |
| 104 | erasures[erasures_count] = i; |
| 105 | erasures_count++; |
| 106 | } |
| 107 | if (i < k) { |
| 108 | data[i] = (*decoded)[i].c_str(); |
| 109 | } else { |
| 110 | coding[i - k] = (*decoded)[i].c_str(); |
| 111 | } |
| 112 | } |
| 113 | erasures[erasures_count] = -1; |
| 114 | ceph_assert(erasures_count > 0); |
| 115 | return isa_decode(erasures, data, coding, blocksize); |
| 116 | } |
| 117 | |
| 118 | int ErasureCodeIsa::encode_chunks(const shard_id_map<bufferptr> &in, |
| 119 | shard_id_map<bufferptr> &out) |