diff options
-rw-r--r-- | block/blk-merge.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index 0e5643a5d1c3..237b087d3529 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -83,9 +83,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, | |||
83 | struct bio *new = NULL; | 83 | struct bio *new = NULL; |
84 | 84 | ||
85 | bio_for_each_segment(bv, bio, iter) { | 85 | bio_for_each_segment(bv, bio, iter) { |
86 | if (sectors + (bv.bv_len >> 9) > queue_max_sectors(q)) | ||
87 | goto split; | ||
88 | |||
89 | /* | 86 | /* |
90 | * If the queue doesn't support SG gaps and adding this | 87 | * If the queue doesn't support SG gaps and adding this |
91 | * offset would create a gap, disallow it. | 88 | * offset would create a gap, disallow it. |
@@ -93,6 +90,22 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, | |||
93 | if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset)) | 90 | if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset)) |
94 | goto split; | 91 | goto split; |
95 | 92 | ||
93 | if (sectors + (bv.bv_len >> 9) > | ||
94 | blk_max_size_offset(q, bio->bi_iter.bi_sector)) { | ||
95 | /* | ||
96 | * Consider this a new segment if we're splitting in | ||
97 | * the middle of this vector. | ||
98 | */ | ||
99 | if (nsegs < queue_max_segments(q) && | ||
100 | sectors < blk_max_size_offset(q, | ||
101 | bio->bi_iter.bi_sector)) { | ||
102 | nsegs++; | ||
103 | sectors = blk_max_size_offset(q, | ||
104 | bio->bi_iter.bi_sector); | ||
105 | } | ||
106 | goto split; | ||
107 | } | ||
108 | |||
96 | if (bvprvp && blk_queue_cluster(q)) { | 109 | if (bvprvp && blk_queue_cluster(q)) { |
97 | if (seg_size + bv.bv_len > queue_max_segment_size(q)) | 110 | if (seg_size + bv.bv_len > queue_max_segment_size(q)) |
98 | goto new_segment; | 111 | goto new_segment; |