fscrypt_limit_io_blocks(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 at lblk. 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 πŸ‘‘

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