Introduce blk_crypto_supported, Filesystems may use this to check wheather
storage device support inline encryption.

Signed-off-by: Fengnan Chang <[email protected]>
---
 block/blk-crypto.c         | 6 +++++-
 include/linux/blk-crypto.h | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/block/blk-crypto.c b/block/blk-crypto.c
index a496aaef85ba..bef0833f9621 100644
--- a/block/blk-crypto.c
+++ b/block/blk-crypto.c
@@ -363,7 +363,11 @@ bool blk_crypto_config_supported(struct request_queue *q,
        return IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) ||
               __blk_crypto_cfg_supported(q->crypto_profile, cfg);
 }
-
+bool blk_crypto_supported(struct request_queue *q)
+{
+       return IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) ||
+              q->crypto_profile;
+}
 /**
  * blk_crypto_start_using_key() - Start using a blk_crypto_key on a device
  * @key: A key to use on the device
diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h
index 69b24fe92cbf..6806cef24d0f 100644
--- a/include/linux/blk-crypto.h
+++ b/include/linux/blk-crypto.h
@@ -103,6 +103,7 @@ int blk_crypto_evict_key(struct request_queue *q,
 bool blk_crypto_config_supported(struct request_queue *q,
                                 const struct blk_crypto_config *cfg);
 
+bool blk_crypto_supported(struct request_queue *q);
 #else /* CONFIG_BLK_INLINE_ENCRYPTION */
 
 static inline bool bio_has_crypt_ctx(struct bio *bio)
@@ -110,6 +111,10 @@ static inline bool bio_has_crypt_ctx(struct bio *bio)
        return false;
 }
 
+static inline bool blk_crypto_supported(struct request_queue *q)
+{
+       return false;
+}
 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */
 
 int __bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask);
-- 
2.32.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to