Skip to content

Commit 3aa8c01

Browse files
bvanasschekawasaki
authored andcommitted
block: Split blk_crypto_fallback_split_bio_if_needed()
Prepare for calling blk_crypto_max_io_size() from the bio splitting code. No functionality has been changed. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 198825c commit 3aa8c01

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

block/blk-crypto-fallback.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ blk_crypto_fallback_alloc_cipher_req(struct blk_crypto_keyslot *slot,
209209
return true;
210210
}
211211

212-
static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
212+
/*
213+
* The encryption fallback code allocates bounce pages individually. This limits
214+
* the bio size supported by the encryption fallback code. This function
215+
* calculates the upper limit for the bio size.
216+
*/
217+
static unsigned int blk_crypto_max_io_size(struct bio *bio)
213218
{
214-
struct bio *bio = *bio_ptr;
215219
unsigned int i = 0;
216220
unsigned int num_sectors = 0;
217221
struct bio_vec bv;
@@ -222,6 +226,16 @@ static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
222226
if (++i == BIO_MAX_VECS)
223227
break;
224228
}
229+
230+
return num_sectors;
231+
}
232+
233+
static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
234+
{
235+
struct bio *bio = *bio_ptr;
236+
unsigned int num_sectors;
237+
238+
num_sectors = blk_crypto_max_io_size(bio);
225239
if (num_sectors < bio_sectors(bio)) {
226240
struct bio *split_bio;
227241

0 commit comments

Comments
 (0)