aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-merge.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index a1ead9049ed6..05c17be0eea4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -86,6 +86,9 @@ EXPORT_SYMBOL(blk_recount_segments);
86static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, 86static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
87 struct bio *nxt) 87 struct bio *nxt)
88{ 88{
89 struct bio_vec end_bv, nxt_bv;
90 struct bvec_iter iter;
91
89 if (!blk_queue_cluster(q)) 92 if (!blk_queue_cluster(q))
90 return 0; 93 return 0;
91 94
@@ -96,14 +99,20 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
96 if (!bio_has_data(bio)) 99 if (!bio_has_data(bio))
97 return 1; 100 return 1;
98 101
99 if (!BIOVEC_PHYS_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt))) 102 bio_for_each_segment(end_bv, bio, iter)
103 if (end_bv.bv_len == iter.bi_size)
104 break;
105
106 nxt_bv = bio_iovec(nxt);
107
108 if (!BIOVEC_PHYS_MERGEABLE(&end_bv, &nxt_bv))
100 return 0; 109 return 0;
101 110
102 /* 111 /*
103 * bio and nxt are contiguous in memory; check if the queue allows 112 * bio and nxt are contiguous in memory; check if the queue allows
104 * these two to be merged into one 113 * these two to be merged into one
105 */ 114 */
106 if (BIO_SEG_BOUNDARY(q, bio, nxt)) 115 if (BIOVEC_SEG_BOUNDARY(q, &end_bv, &nxt_bv))
107 return 1; 116 return 1;
108 117
109 return 0; 118 return 0;