Re: [PATCH v8 09/11] fscrypt: add inline encryption support

Eric Biggers
2020-03-15T17:20:09Z

On Thu, Mar 12, 2020 at 01:02:51AM -0700, Satya Tangirala wrote:
> +int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
> + const u8 *raw_key,
> + const struct fscrypt_info *ci)
> +{
> + const struct inode *inode = ci->ci_inode;
> + struct super_block *sb = inode->i_sb;
> + enum blk_crypto_mode_num crypto_mode = ci->ci_mode->blk_crypto_mode;
> + unsigned int blk_crypto_dun_bytes;

'blk_crypto_dun_bytes' is overly verbose. 'dun_bytes' would still be just as
clear.

This comment also applies to the parameter to blk_crypto_init_key().

> +/**
> + * fscrypt_set_bio_crypt_ctx_bh - prepare a file contents bio for inline
> + * encryption
> + * @bio: a bio which will eventually be submitted to the file
> + * @first_bh: the first buffer_head for which I/O will be submitted
> + * @gfp_mask: memory allocation flags
> + *
> + * Same as fscrypt_set_bio_crypt_ctx(), except this takes a buffer_head instead
> + * of an inode and block number directly.
> + */
> +void fscrypt_set_bio_crypt_ctx_bh(struct bio *bio,
> + const struct buffer_head *first_bh,
> + gfp_t gfp_mask)
> +{
> + const struct inode *inode;
> + u64 first_lblk;
> +
> + if (bh_get_inode_and_lblk_num(first_bh, &inode, &first_lblk))
> + fscrypt_set_bio_crypt_ctx(bio, inode, first_lblk, gfp_mask);
> +}
> +EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx_bh);

Nit: the continuation lines for the function arguments aren't aligned.

- Eric