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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ba99351c0f58..b3ac40aef46b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -99,16 +99,17 @@ void blk_recount_segments(struct request_queue *q, struct bio *bio)
99{ 99{
100 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, 100 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE,
101 &q->queue_flags); 101 &q->queue_flags);
102 bool merge_not_need = bio->bi_vcnt < queue_max_segments(q);
102 103
103 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) && 104 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) &&
104 bio->bi_vcnt < queue_max_segments(q)) 105 merge_not_need)
105 bio->bi_phys_segments = bio->bi_vcnt; 106 bio->bi_phys_segments = bio->bi_vcnt;
106 else { 107 else {
107 struct bio *nxt = bio->bi_next; 108 struct bio *nxt = bio->bi_next;
108 109
109 bio->bi_next = NULL; 110 bio->bi_next = NULL;
110 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, 111 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio,
111 no_sg_merge); 112 no_sg_merge && merge_not_need);
112 bio->bi_next = nxt; 113 bio->bi_next = nxt;
113 } 114 }
114 115