Re: [PATCH 2/2] blk-crypto: add a blk_crypto_cfg_supported helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 04, 2022 at 06:46:21AM +0100, Christoph Hellwig wrote:
> Add a blk_crypto_cfg_supported helper that wraps
> __blk_crypto_cfg_supported to retreive the crypto_profile from the
> request queue.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  block/blk-crypto-profile.c         |  7 +++++++
>  block/blk-crypto.c                 | 13 ++++---------
>  fs/crypto/inline_crypt.c           |  4 +---
>  include/linux/blk-crypto-profile.h |  2 ++
>  4 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/block/blk-crypto-profile.c b/block/blk-crypto-profile.c
> index 96c511967386d..e8a0a3457fa29 100644
> --- a/block/blk-crypto-profile.c
> +++ b/block/blk-crypto-profile.c
> @@ -353,6 +353,13 @@ bool __blk_crypto_cfg_supported(struct blk_crypto_profile *profile,
>  	return true;
>  }
>  
> +bool blk_crypto_cfg_supported(struct block_device *bdev,
> +			      const struct blk_crypto_config *cfg)
> +{
> +	return __blk_crypto_cfg_supported(bdev_get_queue(bdev)->crypto_profile,
> +					  cfg);
> +}

I think this part is too confusing, because there's already a function
blk_crypto_config_supported() which does something slightly different.

How about calling this blk_crypto_config_supported_natively() instead?  It's
kind of long, but it's much clearer.

Also, it should be defined in blk-crypto.c, next to
blk_crypto_config_supported(), and not in blk-crypto-profile.c.
(And declared in blk-crypto.h, not blk-crypto-profile.h.)

This would also make it so that fs/crypto/inline_crypt.c could go back to
including blk-crypto.h instead of blk-crypto-profile.h.  blk-crypto.h is
supposed to be the interface to upper layers, not blk-crypto-profile.h.

So, something like this:

	bool blk_crypto_config_supported(struct block_device *bdev,
					 const struct blk_crypto_config *cfg)
	{
		return IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) ||
		       blk_crypto_config_supported_natively(bdev, cfg);
	}

	bool blk_crypto_config_supported_natively(struct block_device *bdev,
						  const struct blk_crypto_config *cfg)
	{
		return __blk_crypto_cfg_supported(bdev_get_queue(bdev)->crypto_profile,
						  cfg);
	}

- Eric



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux