2019-10-09 18:06:43 +02:00
|
|
|
This is a device mapper block compression driver.
|
|
|
|
|
|
|
|
Note:
|
|
|
|
- Sectors are always 512 bytes (kernel constant).
|
2019-11-12 22:25:46 +01:00
|
|
|
- Physical blocks are variable 512b .. 4kb.
|
|
|
|
- Logical blocks are variable 4kb .. 4mb.
|
2019-10-09 18:06:43 +02:00
|
|
|
- All integers are little endian.
|
|
|
|
|
|
|
|
Block device layout:
|
2019-11-12 22:25:46 +01:00
|
|
|
- pblk[0] header (512 bytes)
|
|
|
|
/* Offset 0: magic and version */
|
2019-10-09 18:06:43 +02:00
|
|
|
- byte[4] magic
|
|
|
|
- u16 version_major
|
|
|
|
- u16 version_minor
|
2019-11-12 22:25:46 +01:00
|
|
|
/* Offset 8: parameters */
|
2019-11-04 21:25:54 +01:00
|
|
|
- u16 flags
|
2019-11-14 00:13:12 +01:00
|
|
|
- u8 compression
|
|
|
|
hi nybble: algorithm (1=lz4, 2=zlib, ...) [1]
|
|
|
|
lo nybble: level (1..9) [1]
|
2019-11-12 22:25:46 +01:00
|
|
|
- u8 pblk_shift (0..3) [3 = 4kb]
|
|
|
|
- u8 lblk_shift (1..10) [4 = 64kb (*)]
|
2019-11-14 00:13:12 +01:00
|
|
|
- u8 lba_elem_pblk_bytes (2, 4, 6)
|
|
|
|
- u8 pbat_shift [0]
|
|
|
|
- u8 pad
|
2019-11-04 21:25:54 +01:00
|
|
|
- u32 nr_zones
|
|
|
|
- u32 lblk_per_zone
|
2019-11-12 22:25:46 +01:00
|
|
|
- byte[40] reserved
|
|
|
|
/* Offset 64: stats */
|
|
|
|
- u64 pblk_used
|
|
|
|
- u64 lblk_used
|
|
|
|
- byte[48] reserved
|
|
|
|
/* Offset 128: reserved */
|
|
|
|
- byte[384] reserved
|
|
|
|
- pblk[] zone ... vector of zone
|
|
|
|
|
|
|
|
(*) The maximum lblk_shift may be (and usually is) less than 10 because
|
|
|
|
lblk_alloc size must be <= pblk size. When pblk_shift=1 (1024) and
|
|
|
|
lblk_alloc_16_32, the maximum lblk_shift is 8 (256kb).
|
2019-10-09 18:06:43 +02:00
|
|
|
|
|
|
|
Device size limits:
|
2019-11-04 21:25:54 +01:00
|
|
|
- Min: header plus one zone (header, pbat, lbat, data)
|
2019-10-09 18:06:43 +02:00
|
|
|
Arbitrarily limit to 1mb (?)
|
2019-11-04 21:25:54 +01:00
|
|
|
- Max: 2^48 pblk = 1eb
|
2019-10-09 18:06:43 +02:00
|
|
|
|
|
|
|
There are six different lblk_alloc sizes:
|
|
|
|
Struct name Size lblk_size device_pblk_size
|
|
|
|
=========== ==== ========= ================
|
|
|
|
lblk_alloc_16_16 2+2*8 <= 64kb <= 64k
|
|
|
|
lblk_alloc_16_32 2+4*8 <= 64kb <= 4g
|
|
|
|
lblk_alloc_16_48 2+6*8 <= 64kb <= 256t
|
|
|
|
lblk_alloc_32_16 4+2*8 > 64kb <= 64k
|
|
|
|
lblk_alloc_32_32 4+4*8 > 64kb <= 4g
|
|
|
|
lblk_alloc_32_48 4+6*8 > 64kb <= 256t
|
|
|
|
|
|
|
|
|
|
|
|
Zone layout:
|
2019-11-12 22:25:46 +01:00
|
|
|
- byte[pblk_size*pbat_len] Physical block allocation table (pbat)
|
|
|
|
- lblk_alloc_x_y[] Logical block allocation table (lbat)
|
|
|
|
Note: padded to pblk size
|
|
|
|
- data[] Data
|
|
|
|
One pblk per bit in pbat
|