Skip to content

Commit

Permalink
block: fix "check bi_size overflow before merge"
Browse files Browse the repository at this point in the history
This partially reverts commit e3a5d8e.

Commit e3a5d8e ("check bi_size overflow before merge") adds a bio_full
check to __bio_try_merge_page.  This will cause __bio_try_merge_page to fail
when the last bi_io_vec has been reached.  Instead, what we want here is only
the bi_size overflow check.

Fixes: e3a5d8e ("block: check bi_size overflow before merge")
Cc: stable@vger.kernel.org # v5.4+
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Andreas Gruenbacher authored and axboe committed Dec 10, 2019
1 parent dc3ecfc commit cc90bc6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,12 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
return false;

if (bio->bi_vcnt > 0 && !bio_full(bio, len)) {
if (bio->bi_vcnt > 0) {
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];

if (page_is_mergeable(bv, page, len, off, same_page)) {
if (bio->bi_iter.bi_size > UINT_MAX - len)
return false;
bv->bv_len += len;
bio->bi_iter.bi_size += len;
return true;
Expand Down

0 comments on commit cc90bc6

Please sign in to comment.