Skip to content

Add LZ4 decompression support for full lcluster layout#36

Open
katexochen wants to merge 1 commit into
erofs:mainfrom
katexochen:compression
Open

Add LZ4 decompression support for full lcluster layout#36
katexochen wants to merge 1 commit into
erofs:mainfrom
katexochen:compression

Conversation

@katexochen

Copy link
Copy Markdown

This is the first in a series of patches adding compression support. I tried t split this into revieweable chunks that work as stand-alone additions.


Adds read support for LZ4-compressed EROFS images using the full (legacy) lcluster index layout. Compact layout, ztailpacking, fragments, big_pcluster_2, HEAD2 / LZMA / DEFLATE / Zstd remain deferred — they return clear ErrNotImplemented at read time.

New internal/zerofs package owns the z_erofs read path: map-header parsing & validation, full-layout lcluster decoding, pcluster resolution (preroll + big_pcluster_1), and a partial LZ4 block decoder that handles the EROFS LZ4_0Padding variant (leading zero inputmargin + stop-at-output-cap semantics, equivalent to the kernel's LZ4_decompress_safe_partial).

erofs.go gains parseComprCfgs, loadCompressedBlock, an image-level pcluster LRU, and the superblock check is relaxed: the ComprAlgs field is now correctly treated as a union (lz4_max_distance pre- COMPR_CFGS, an algorithm bitmap when COMPR_CFGS is set).

Tests cover the standard TestCases run through an LZ4 converter, compressibility edge cases, multi-pcluster spanning reads, plain-vs- LZ4 cross-validation, fuzz of compressed image bytes, and a deferred-feature check asserting compact-layout images error cleanly.

Adds read support for LZ4-compressed EROFS images using the full
(legacy) lcluster index layout. Compact layout, ztailpacking,
fragments, big_pcluster_2, HEAD2 / LZMA / DEFLATE / Zstd remain
deferred — they return clear ErrNotImplemented at read time.

New internal/zerofs package owns the z_erofs read path: map-header
parsing & validation, full-layout lcluster decoding, pcluster
resolution (preroll + big_pcluster_1), and a partial LZ4 block
decoder that handles the EROFS LZ4_0Padding variant (leading zero
inputmargin + stop-at-output-cap semantics, equivalent to the
kernel's LZ4_decompress_safe_partial).

erofs.go gains parseComprCfgs, loadCompressedBlock, an image-level
pcluster LRU, and the superblock check is relaxed: the ComprAlgs
field is now correctly treated as a union (lz4_max_distance pre-
COMPR_CFGS, an algorithm bitmap when COMPR_CFGS is set).

Tests cover the standard TestCases run through an LZ4 converter,
compressibility edge cases, multi-pcluster spanning reads, plain-vs-
LZ4 cross-validation, fuzz of compressed image bytes, and a
deferred-feature check asserting compact-layout images error cleanly.

Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant