Prepare for calling blk_crypto_max_io_size() from the bio splitting code. No functionality has been changed. Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- block/blk-crypto-fallback.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 3c914d2c054f..98bba0cf89cc 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -209,11 +209,15 @@ blk_crypto_fallback_alloc_cipher_req(struct blk_crypto_keyslot *slot, return true; } -static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr) +/* + * The encryption fallback code allocates bounce pages individually. This limits + * the bio size supported by the encryption fallback code. This function + * calculates the upper limit for the bio size. + */ +static unsigned int blk_crypto_max_io_size(struct bio *bio) { - struct bio *bio = *bio_ptr; unsigned int i = 0; - unsigned int num_bytes = 0, num_sectors; + unsigned int num_bytes = 0; struct bio_vec bv; struct bvec_iter iter; @@ -222,7 +226,14 @@ static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr) if (++i == BIO_MAX_VECS) break; } - num_sectors = num_bytes >> SECTOR_SHIFT; + return num_bytes >> SECTOR_SHIFT; +} + +static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr) +{ + struct bio *bio = *bio_ptr; + unsigned int num_sectors = blk_crypto_max_io_size(bio); + if (num_sectors < bio_sectors(bio)) { struct bio *split_bio;