blk-crypto.c (07560151db960d26b425410d6fd778e6757a5da2) blk-crypto.c (93f221ae08381e994ac9f9ff6aa743e612e49718)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2019 Google LLC
4 */
5
6/*
7 * Refer to Documentation/block/inline-encryption.rst for detailed explanation.
8 */

--- 269 unchanged lines hidden (view full) ---

278
279 if (blk_crypto_fallback_bio_prep(bio_ptr))
280 return true;
281fail:
282 bio_endio(*bio_ptr);
283 return false;
284}
285
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2019 Google LLC
4 */
5
6/*
7 * Refer to Documentation/block/inline-encryption.rst for detailed explanation.
8 */

--- 269 unchanged lines hidden (view full) ---

278
279 if (blk_crypto_fallback_bio_prep(bio_ptr))
280 return true;
281fail:
282 bio_endio(*bio_ptr);
283 return false;
284}
285
286/**
287 * __blk_crypto_rq_bio_prep - Prepare a request's crypt_ctx when its first bio
288 * is inserted
289 *
290 * @rq: The request to prepare
291 * @bio: The first bio being inserted into the request
292 * @gfp_mask: gfp mask
293 */
294void __blk_crypto_rq_bio_prep(struct request *rq, struct bio *bio,
295 gfp_t gfp_mask)
286int __blk_crypto_rq_bio_prep(struct request *rq, struct bio *bio,
287 gfp_t gfp_mask)
296{
288{
297 if (!rq->crypt_ctx)
289 if (!rq->crypt_ctx) {
298 rq->crypt_ctx = mempool_alloc(bio_crypt_ctx_pool, gfp_mask);
290 rq->crypt_ctx = mempool_alloc(bio_crypt_ctx_pool, gfp_mask);
291 if (!rq->crypt_ctx)
292 return -ENOMEM;
293 }
299 *rq->crypt_ctx = *bio->bi_crypt_context;
294 *rq->crypt_ctx = *bio->bi_crypt_context;
295 return 0;
300}
301
302/**
303 * blk_crypto_init_key() - Prepare a key for use with blk-crypto
304 * @blk_key: Pointer to the blk_crypto_key to initialize.
305 * @raw_key: Pointer to the raw key. Must be the correct length for the chosen
306 * @crypto_mode; see blk_crypto_modes[].
307 * @crypto_mode: identifier for the encryption algorithm to use

--- 100 unchanged lines hidden ---
296}
297
298/**
299 * blk_crypto_init_key() - Prepare a key for use with blk-crypto
300 * @blk_key: Pointer to the blk_crypto_key to initialize.
301 * @raw_key: Pointer to the raw key. Must be the correct length for the chosen
302 * @crypto_mode; see blk_crypto_modes[].
303 * @crypto_mode: identifier for the encryption algorithm to use

--- 100 unchanged lines hidden ---