The Comprehensive Ceph Guide
فارسیGet started

Erasure coding: split, lose, rebuild

In the book: Chapter 13

Lab

Erasure coding: split, lose, rebuild

Split 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 / 6shards healthy
0more failures tolerated
13 B × 6chunk size
1.5×storage overhead (k+m)/k
52 Bread to rebuild one shard

shard 0 data

43 65 70 68 20 6b 65 65 70 73 20 65 …
“Ceph keeps ev”
Read for this request

shard 1 data

lost

This shard's OSD is down

shard 2 data

66 65 2c 20 6f 6e 65 20 63 68 75 6e …
“fe, one chunk”
Read for this request

shard 3 data

20 61 74 20 61 20 74 69 6d 65 2e 00 …
“ at a time.··”
Read for this request

shard 4 parity

lost

This shard's OSD is down

shard 5 parity

11 27 b5 b5 70 17 bf 40 68 29 c4 26 …
Read for this request

Rebuilt from shards 0, 2, 3, 5 ✓

Ceph keeps every object safe, one chunk at a time.
Inverse matrix (rows of the shards read)
D01000
D114224142
D20100
D30010
isa coding matrix (parity rows)
P41111
P51248
Pi[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 chunks

With 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 profile
A fixed snapshot of the simulator; the interactive version is in the web edition's lab. Interactive lab: Erasure coding: split, lose, rebuild