Go to file
Tom Marshall 7b50dc7de7 Add explicit include for pagemap.h
This is required by newer kernels.
2022-01-16 11:05:44 -08:00
cbd WIP: Add info command 2021-05-22 09:57:10 -07:00
dm-compress Add explicit include for pagemap.h 2022-01-16 11:05:44 -08:00
include WIP: Add info command 2021-05-22 09:57:10 -07:00
libcbd WIP: Add info command 2021-05-22 09:57:10 -07:00
.gitignore Add ignore for newer kernel module build outputs 2021-05-17 13:36:46 -07:00
Makefile WIP: Add info command 2021-05-22 09:57:10 -07:00
README Remove variable pblk and pbat sizes, optimize, and cleanup 2021-05-17 13:36:40 -07:00
TODO Reset objects outside cache lock 2019-11-04 11:36:20 -08:00

README

This is a device mapper block compression driver.

Note:
  - Sectors are always 512 bytes (kernel constant).
  - Physical blocks are always 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                    lblk_shift (1..10) [4 = 64kb (*)]
    - u8                    lba_elem_pblk_bytes (2, 4, 6)
    - u8[3]                 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 less than 10 because lblk_alloc size
    must be <= pblk size.

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_shift      lblk_size       device pblks
  ===========           =====   ==========      =========       ============
  lblk_alloc_16_16      2+2*n   1..10           <= 64kb         <= 64k
  lblk_alloc_16_32      2+4*n   1..9            <= 64kb         <= 4g
  lblk_alloc_16_48      2+6*n   1..9            <= 64kb         <= 256t
  lblk_alloc_32_16      4+2*n   1..10           > 64kb          <= 64k
  lblk_alloc_32_32      4+4*n   1..9            > 64kb          <= 4g
  lblk_alloc_32_48      4+6*n   1..9            > 64kb          <= 256t


Zone layout:
  - byte[pblk_size]     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