smb_lz77_com...d_alloc_size(9)
π smb_lz77_compressed_alloc_size(9) β Kernel API Manual, bestie edition
okay so this is a kernel API manual page for smb_lz77_compressed_alloc_size(9), and yes the name is a whole mouthful β the man page header literally abbreviates it as smb_lz77_com...d_alloc_size(9) so you're not alone if your eyes glazed over π«Ά
β¨ NAME β¨
smb_lz77_compressed_alloc_size β literally just "Compute compressed buffer size." that's it, that's the job π
πΈ SYNOPSIS πΈ
u32 smb_lz77_compressed_alloc_size (const u32 size );
π ARGUMENTS π
sizeβ the uncompressed (src) size. the raw, un-smooshed number before any compression happens π¦
π DESCRIPTION π
So what this icon does is compute the allocation size for the compressed buffer, based on the uncompressed size you hand it. It accounts for the metadata, and it overprovisions for the worst case scenario β because we are not about to get caught lacking π
Here's the tea on LZ77 metadata: it's a 4-byte flag, and it gets written:
- on dst begin (pos 0) π
- every 32 literals or matches π
- on end-of-stream (possibly, if the last write was another flag) π
The worst case scenario is an all-literal compression, which means:
metadata bytes = 4 + ((size / 32) * 4) + 4
or, simplified, bestie:
(size >> 3) + 8
Now, the worst case scenario rarely happens ngl β but this overprovisioning is lowkey iconic for two reasons: it lets the smb_lz77_compress main loop run without ever bound checking dst, which is a huge perf improvement π₯, and it's still safe when compression goes bad. best of both worlds, we love to see it π
The (*) footnote situation is checked once in the beginning of smb_lz77_compress β just the one time, no cap π§
β RETURN β
The required (*) allocation size for the compressed buffer. take it, it's yours π«Ά
π SEE ALSO π
- Kernel file
./fs/smb/common/compress/lz77.hβ go read it, it's giving main character energy π
lowkey reminder: the (*) marker is doing real work here, don't skip it π
and that's the whole page, bestie β sourced from ./fs/smb/common/compress, dated October 2026, manual section 9, and the header/footer both spell it smb_lz77_com...d_alloc_size(9) because sometimes even man pages need a nickname πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms