# Erasure coding: split, lose, rebuild

*HTML: https://book.ceph-s3.ir/en/lab-ecdecode.html*
*Licence: CC BY-NC-SA 4.0. Author: Ramin Najarbashi.*

[Interactive lab](lab.html)Erasure coding: split, lose, rebuild
In the book: [Chapter 13](13-erasure-coding.html#sec-13-9-1)
LabErasure coding: split, lose, rebuildSplit a text into k data chunks and m parity chunks, fail any shards you like, and see which chunks are read and how the text comes back by inverting a matrix in GF(2⁸).**4 / 6**shards healthy**0**more failures tolerated**13 B × 6**chunk size**1.5×**storage overhead (k+m)/k**52 B**read to rebuild one shardshard 0 data43 65 70 68 20 6b 65 65 70 73 20 65 …“Ceph keeps ev”Read for this requestshard 1 datalostThis shard's OSD is downshard 2 data66 65 2c 20 6f 6e 65 20 63 68 75 6e …“fe, one chunk”Read for this requestshard 3 data20 61 74 20 61 20 74 69 6d 65 2e 00 …“ at a time.··”Read for this requestshard 4 paritylostThis shard's OSD is downshard 5 parity11 27 b5 b5 70 17 bf 40 68 29 c4 26 …Read for this requestRebuilt from shards 0, 2, 3, 5 ✓Ceph keeps every object safe, one chunk at a time.Inverse matrix (rows of the shards read)D01000D114224142D20100D30010isa coding matrix (parity rows)P41111P51248Pi[b] = ⊕j M[i][j] · Dj[b] in GF(2⁸), polynomial 0x11d · read for decode: {0,2,3,5} (all data shards if present, else the first k available) · rebuilding one lost shard reads k = 4 chunksWith 3x replication, rebuilding a copy reads one copy; with EC k chunks must be read from k OSDs, so repair costs more and a large k makes it worse (chapter 13). Once a data chunk is lost, even a normal read has to decode.Follows:`jerasure src/reed_sol.c :: reed_sol_vandermonde_coding_matrix, reed_sol_big_vandermonde_distribution_matrix` The jerasure coding matrix`isa-l erasure_code/ec_base.c :: gf_gen_rs_matrix, ec_encode_data_base` The ISA-L matrix and encoder`src/erasure-code/ErasureCode.cc :: ErasureCode::_minimum_to_decode` Which chunks a read needs`src/erasure-code/jerasure/ErasureCodeJerasure.cc, src/erasure-code/isa/ErasureCodeIsa.cc :: technique=reed_sol_van` The jerasure and isa plugins`src/common/options/global.yaml.in :: osd_pool_default_erasure_code_profile (plugin=isa technique=reed_sol_van k=2 m=2)` The default profileA fixed snapshot of the simulator; the interactive version is in the web edition's lab. [Interactive lab: Erasure coding: split, lose, rebuild](lab-ecdecode.html)The interactive version needs JavaScript; this is a fixed snapshot.
