On Wed, Dec 17, 2025 at 07:06:48AM +0100, Christoph Hellwig wrote:
> + if (++enc_idx == enc_bio->bi_max_vecs) {
> + /*
> + * For each additional encrypted bio submitted,
> + * increment the source bio's remaining count. Each
> + * encrypted bio's completion handler calls bio_endio on
> + * the source bio, so this keeps the source bio from
> + * completing until the last encrypted bio does.
> + */
> + bio_inc_remaining(src_bio);
> + submit_bio(enc_bio);
> + goto new_bio;
> + }
Actually I think using bi_max_vecs is broken.
This code assumes that bi_max_vecs matches the nr_segs that was passed
to bio_alloc_bioset().
That assumption is incorrect, though. If nr_segs > 0 && nr_segs <
BIO_INLINE_VECS, bio_alloc_bioset() sets bi_max_vecs to BIO_INLINE_VECS.
BIO_INLINE_VECS is 4.
I think blk_crypto_alloc_enc_bio() will need to return a nr_enc_pages
value. That value will need to be used above as well as at
out_free_enc_bio, instead of bi_max_vecs.
- Eric