Skip to contentSkip to conversation

block: fix updating bio's front segment size

PATCH Applied Ming Lei 2 participants 2 messages Mar 2, 2019 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: fix updating bio's front segment size

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 <[email protected]>
Cc Omar Sandoval <[email protected]>
Fixes dcebd755926b ("block: use bio_for_each_bvec() to compute multi-page bvec count")
---
 block/blk-merge.c | 8 ++++++++
 1 file changed, 8 insertions(+)
block/blk-merge.c +8 -0
index 9402a7c3ba22..22467f475ab4 100644
@@ -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:
Signature · 1 line
2.9.5
maintainer Applied
#1 lore raw
Quoted 7 lines · Ming Lei

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.

Signature · 1 line
Jens Axboe