fscrypt_encr...cache_blocks(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… fscrypt_encrypt_pagecache_blocks(9) β€” like, the whole kernel API manual vibe, bestie ✨

okay so real talk, this page lives in the Kernel API Manual and it's the whole fscrypt_encr...cache_blocks(9) situation. yes the title got truncated, no that's not my fault, the terminal is just built like that πŸ™ˆ anyway. sit down, grab a strawberry drink πŸ“, we're learning how pagecache folios get encrypted.


✨ NAME ✨

fscrypt_encrypt_pagecache_blocks β€” encrypt data from a pagecache folio πŸŽ€

like... that's literally her job. that's the whole thing.


🌸 SYNOPSIS 🌸

struct page * fscrypt_encrypt_pagecache_blocks (struct folio *folio ,
size_t len , size_t offs , gfp_t gfp_flags );

look at that signature. iconic. no notes. πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • folio β€” the locked pagecache folio holding the data you wanna encrypt. key word being locked, bestie, do not come in here unlocked πŸ”’
  • len β€” size of the data to encrypt, in bytes πŸ“
  • offs β€” offset within the page where the data to encrypt starts, in bytes πŸ“
  • gfp_flags β€” memory allocation flags; the deets are down below, keep reading πŸ‘€

πŸ’– DESCRIPTION πŸ’–

so what actually happens? this thingy allocates a brand new bounce page and encrypts the given data into it. that's the move. 🫢

the length and the offset of the data must be aligned to the file's crypto data unit size, no cap. and here's the cute part: aligning to the filesystem block size totally fulfills this requirement, because the filesystem block size is always a multiple of the data unit size. math said slay. 🧚

in the bounce page, the ciphertext data ends up at the same offset where the plaintext data was sitting in the source page. matching. coordinated. outfits on point. πŸ‘‘

⚠️ okay but any other parts of that bounce page? left uninitialized. do not go reading them, do not go trusting them, they are not your friends. πŸ’€

this one is for use by the ->writepages method of non-block-based filesystems. iykyk.

now the allocation tea β˜• β€” the bounce page allocation is mempool-backed, so it will always succeed when gfp_flags includes __GFP_DIRECT_REclaim... wait no, __GFP_DIRECT_RECLAIM, e.g. when it's GFP_NOFS. slay, guaranteed. πŸ’…

however (and this is the big however, the main character plot twist): only the first page of each bio can be allocated this way. to prevent deadlocks, for any additional pages you must use a mask like GFP_NOWAIT. periodt. don't skip this part or you're gonna have a bad time 😭


🌈 RETURN 🌈

  • βœ… the new encrypted bounce page on success
  • πŸ’€ an ERR_PTR on failure

that's it. that's the whole return. she's simple, she's effective.


⭐ SEE ALSO ⭐

go touch some other pages, bestie:


okay that's the whole page!! mwah πŸ’‹ this little baddie comes to you straight out of ./fs/crypto, dated October 2026, and yes she's still doing the fscrypt_encr...cache_blocks(9) thing in the corner. go encrypt responsibly, ily, bye πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from