Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-crypto: add a bio_crypt_ctx() helper

This returns the bio_crypt_ctx if CONFIG_BLK_INLINE_ENCRYPTION is enabled
and a crypto context is attached to the bio, else NULL.

The use case is to allow safely dereferencing the context in common code
without needed #ifdef CONFIG_BLK_INLINE_ENCRYPTION.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
a3cc978e bc26e2ef

+10
+10
include/linux/blk-crypto.h
··· 132 132 return bio->bi_crypt_context; 133 133 } 134 134 135 + static inline struct bio_crypt_ctx *bio_crypt_ctx(struct bio *bio) 136 + { 137 + return bio->bi_crypt_context; 138 + } 139 + 135 140 void bio_crypt_set_ctx(struct bio *bio, const struct blk_crypto_key *key, 136 141 const u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], 137 142 gfp_t gfp_mask); ··· 172 167 static inline bool bio_has_crypt_ctx(struct bio *bio) 173 168 { 174 169 return false; 170 + } 171 + 172 + static inline struct bio_crypt_ctx *bio_crypt_ctx(struct bio *bio) 173 + { 174 + return NULL; 175 175 } 176 176 177 177 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */