Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32eef964 authored by Jens Axboe's avatar Jens Axboe
Browse files

blk_hw_contig_segment(): bad segment size checks



Two bugs in there:

- The virt oversize check should use the current bio hardware back
  size and the next bio front size, not the same bio. Spotted by
  Neil Brown.

- The segment size check should add hw front sizes, not total bio
  sizes. Spotted by James Bottomley

Acked-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
Acked-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 7deeed13
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1304,9 +1304,9 @@ static int blk_hw_contig_segment(request_queue_t *q, struct bio *bio,
	if (unlikely(!bio_flagged(nxt, BIO_SEG_VALID)))
		blk_recount_segments(q, nxt);
	if (!BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)) ||
	    BIOVEC_VIRT_OVERSIZE(bio->bi_hw_front_size + bio->bi_hw_back_size))
	    BIOVEC_VIRT_OVERSIZE(bio->bi_hw_back_size + nxt->bi_hw_front_size))
		return 0;
	if (bio->bi_size + nxt->bi_size > q->max_segment_size)
	if (bio->bi_hw_back_size + nxt->bi_hw_front_size > q->max_segment_size)
		return 0;

	return 1;