Skip to content

Commit 2d8f7f1

Browse files
committed
fscrypt: document gfp_flags for bounce page allocation
Document that fscrypt_encrypt_pagecache_blocks() allocates the bounce page from a mempool, and document what this means for the @gfp_flags argument. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Theodore Ts'o <[email protected]> Signed-off-by: Eric Biggers <[email protected]>
1 parent 796f12d commit 2d8f7f1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/crypto/crypto.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw,
138138
* multiple of the filesystem's block size.
139139
* @offs: Byte offset within @page of the first block to encrypt. Must be
140140
* a multiple of the filesystem's block size.
141-
* @gfp_flags: Memory allocation flags
141+
* @gfp_flags: Memory allocation flags. See details below.
142142
*
143143
* A new bounce page is allocated, and the specified block(s) are encrypted into
144144
* it. In the bounce page, the ciphertext block(s) will be located at the same
@@ -148,6 +148,11 @@ int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw,
148148
*
149149
* This is for use by the filesystem's ->writepages() method.
150150
*
151+
* The bounce page allocation is mempool-backed, so it will always succeed when
152+
* @gfp_flags includes __GFP_DIRECT_RECLAIM, e.g. when it's GFP_NOFS. However,
153+
* only the first page of each bio can be allocated this way. To prevent
154+
* deadlocks, for any additional pages a mask like GFP_NOWAIT must be used.
155+
*
151156
* Return: the new encrypted bounce page on success; an ERR_PTR() on failure
152157
*/
153158
struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,

0 commit comments

Comments
 (0)