Skip to content

Commit

Permalink
block: fix updating bio's front segment size
Browse files Browse the repository at this point in the history
When the current bvec can be merged to the 1st segment, the bio's front
segment size has to be updated.

However, dcebd75 doesn't consider that case, then bio's front
segment size may not be correct.

This patch fixes this issue.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Omar Sandoval <osandov@fb.com>
Fixes: dcebd75 ("block: use bio_for_each_bvec() to compute multi-page bvec count")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Ming Lei authored and Jens Axboe committed Mar 2, 2019
1 parent dfc76d1 commit aaeee62
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
bvprvp = &bvprv;
sectors += bv.bv_len >> 9;

if (nsegs == 1 && seg_size > front_seg_size)
front_seg_size = seg_size;

continue;
}
new_segment:
Expand Down Expand Up @@ -401,6 +404,11 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,

seg_size += bv.bv_len;
bvprv = bv;

if (nr_phys_segs == 1 && seg_size >
front_seg_size)
front_seg_size = seg_size;

continue;
}
new_segment:
Expand Down

0 comments on commit aaeee62

Please sign in to comment.