diff mbox series

block: fix updating bio's front segment size

Message ID 20190302084344.31962-1-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: fix updating bio's front segment size | expand

Commit Message

Ming Lei March 2, 2019, 8:43 a.m. UTC
When the current bvec can be merged to the 1st segment, the bio's front
segment size has to be updated.

However, dcebd755926b 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: dcebd755926b ("block: use bio_for_each_bvec() to compute multi-page bvec count")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-merge.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jens Axboe March 2, 2019, 7:47 p.m. UTC | #1
On 3/2/19 1:43 AM, Ming Lei wrote:
> When the current bvec can be merged to the 1st segment, the bio's front
> segment size has to be updated.
> 
> However, dcebd755926b doesn't consider that case, then bio's front
> segment size may not be correct.
> 
> This patch fixes this issue.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 9402a7c3ba22..22467f475ab4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -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:
@@ -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: