[lustre-devel] [PATCH v2] fscrypt: allow alternative bounce buffers

Sebastien Buisson sbuisson at ddn.com
Mon May 16 08:18:07 PDT 2022


> Le 14 mai 2022 à 21:03, James Simmons <jsimmons at infradead.org> a écrit :
> 
> Currently fscrypt offers two options. One option is to use the
> internal bounce buffer allocated or perform inline encrpytion.
> Add the option to use an external bounce buffer. This change can
> be used useful for example for a network file systems which can
> pass in a page from the page cache and place the encrypted data
> into a page for a network packet to be sent. Another potential
> use is the use of GPU pages with RDMA being the final destination
> for the encrypted data. Lastly in performance measurements the
> allocation of the bounce page incures a heavy cost. Using a page
> from a predefined memory pool can lower the case. We can replace
> the one off case of inplace encryption with the new general
> functions.
> 
> Signed-Off-By: James Simmons <jsimmons at infradead.org>
> ---
> fs/crypto/crypto.c      | 34 +++++++++++++++++++---------------
> fs/ubifs/crypto.c       | 12 +++++++-----
> include/linux/fscrypt.h | 31 ++++++++++++++++---------------
> 3 files changed, 42 insertions(+), 35 deletions(-)
> 
> diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c
> index c57b46a352d8..8233dc2e4969 100644
> --- a/fs/ubifs/crypto.c
> +++ b/fs/ubifs/crypto.c
> @@ -39,8 +39,9 @@ int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
> 	if (pad_len != in_len)
> 		memset(p + in_len, 0, pad_len - in_len);
> 
> -	err = fscrypt_encrypt_block_inplace(inode, virt_to_page(p), pad_len,
> -					    offset_in_page(p), block, GFP_NOFS);
> +	/* Encrypt inplace */
> +	err = fscrypt_encrypt_page(inode, virt_to_page(p), virt_to_page(p),
> +				   pad_len, offset_in_page(p), block, GFP_NOFS);
> 	if (err) {
> 		ubifs_err(c, "fscrypt_encrypt_block_inplace() failed: %d", err);

The error message should be changed as well.

> 		return err;
> @@ -64,9 +65,10 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
> 	}
> 
> 	ubifs_assert(c, dlen <= UBIFS_BLOCK_SIZE);
> -	err = fscrypt_decrypt_block_inplace(inode, virt_to_page(&dn->data),
> -					    dlen, offset_in_page(&dn->data),
> -					    block);
> +	/* Decrypt inplace */
> +	err = fscrypt_decrypt_page(inode, virt_to_page(&dn->data),
> +				   virt_to_page(&dn->data), dlen,
> +				   offset_in_page(&dn->data), block, GFP_NOFS);
> 	if (err) {
> 		ubifs_err(c, "fscrypt_decrypt_block_inplace() failed: %d", err);

The error message should be changed as well.

> 		return err;



More information about the lustre-devel mailing list