smb_lz77_com...d_alloc_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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