fscrypt_encr...cache_blocks(9)
π 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_PTRon failure
that's it. that's the whole return. she's simple, she's effective.
β SEE ALSO β
go touch some other pages, bestie:
- Kernel file
./fs/crypto/crypto.c fscrypt_free_bounce_page(9)fscrypt_encrypt_block_inplace(9)fscrypt_decrypt_block_inplace(9)fscrypt_initialize(9)
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
- 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