fscrypt_limit_io_blocks(9)
π fscrypt_limit_io_blocks(9) π
okay bestie, welcome to the Kernel API Manual β yes, that manual, the one with the actual lore. this is fscrypt_limit_io_blocks(9) and she is lowkey a hero for keeping your encrypted I/O from falling apart π§β¨
β¨ NAME β¨
fscrypt_limit_io_blocks β the function that limits I/O blocks so you don't get discontiguous DUNs π (yes that's a real sentence, stay with me)
πΈ SYNOPSIS πΈ
u64 fscrypt_limit_io_blocks (const struct inode *inode , u64 lblk , u64
nr_blocks );
like, look at her signature. those are the exact types and names, don't touch them π«Ά
π ARGUMENTS π
inodeβ the file that the I/O is being done on. the main character file, obviously πlblkβ the block where the I/O is starting from. the starting point, the beginning of the era β¨nr_blocksβ how many blocks we wanna submit starting atlblk. the wishlist, if you will π
π¦ DESCRIPTION π¦
so here's the vibe: this function figures out the limit to how many blocks can be submitted in a bio targeting lblk without causing a data unit number (DUN) discontiguity. no DUN drama allowed, periodt π
normally, the answer is literally just nr_blocks. because normally the DUNs just increment right along with the logical blocks β cute, simple, iconic. (or, like, the file isn't encrypted at all and we're all just chilling π)
but in rare cases, fscrypt can be using an IV generation method that lets the DUN wrap around within logically contiguous blocks, and that wraparound is gonna happen. and if that's the situation? the function returns a value less than nr_blocks so the wraparound doesn't happen in the middle of a bio.
bestie please understand: a wraparound mid-bio would cause encryption/decryption to produce wrong results. wrong results. WRONG. RESULTS. π this is the whole reason the function exists, do not skip this part.
β RETURN β
the actual number of blocks that can be submitted π (which, reminder, is normally just nr_blocks, but sometimes it's smaller. she keeps you safe either way)
π SEE ALSO π
- Kernel file
./fs/crypto/block.c fscrypt_set_bio_crypt_ctx(9)fscrypt_mergeable_bio(9)fscrypt_zeroout_range(9)
go read them, iykyk πβ¨
and that's the whole page, bestie!! this drop came from the ./fs/crypto directory, dated October 2026, and it's filed under fscrypt_limit_io_blocks(9) β which is also literally the last line of the original page, so yeah, we closed the loop π«Άπ stay encrypted, stay contiguous π¦
π¦ 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