No Description
Tom Marshall 2fab692cdf Implement cbd tune plus some cleanup and rearranging 4 weeks ago
cbd Implement cbd tune plus some cleanup and rearranging 4 weeks ago
dm-compress Make detect zeros a runtime flag 4 weeks ago
include Implement cbd tune plus some cleanup and rearranging 4 weeks ago
libcbd Implement cbd tune plus some cleanup and rearranging 4 weeks ago
.gitignore Add a .gitignore 2 months ago
Makefile Implement cbd tune plus some cleanup and rearranging 4 weeks ago
README Fix variable pblk len, cleanup, rearrange 1 month ago
TODO Reset objects outside cache lock 1 month ago

README

This is a device mapper block compression driver.

Note:
- Sectors are always 512 bytes (kernel constant).
- Physical blocks are variable 512b .. 4kb.
- Logical blocks are variable 4kb .. 4mb.
- All integers are little endian.

Block device layout:
- pblk[0] header (512 bytes)
/* Offset 0: magic and version */
- byte[4] magic
- u16 version_major
- u16 version_minor
/* Offset 8: parameters */
- u16 flags
- u8 compression
hi nybble: algorithm (1=lz4, 2=zlib, ...) [1]
lo nybble: level (1..9) [1]
- u8 pblk_shift (0..3) [3 = 4kb]
- u8 lblk_shift (1..10) [4 = 64kb (*)]
- u8 lba_elem_pblk_bytes (2, 4, 6)
- u8 pbat_shift [0]
- u8 pad
- u32 nr_zones
- u32 lblk_per_zone
- 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).

Device size limits:
- Min: header plus one zone (header, pbat, lbat, data)
Arbitrarily limit to 1mb (?)
- Max: 2^48 pblk = 1eb

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:
- 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