]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
blk-merge: recaculate segment if it isn't less than max segments
authorMing Lei <tom.leiming@gmail.com>
Wed, 22 Oct 2014 00:30:30 +0000 (08:30 +0800)
committerJens Axboe <axboe@fb.com>
Wed, 22 Oct 2014 01:00:32 +0000 (19:00 -0600)
The problem is introduced by commit 764f612c6c3c231b(blk-merge:
don't compute bi_phys_segments from bi_vcnt for cloned bio),
and merge is needed if number of current segment isn't less than
max segments.

Strictly speaking, bio->bi_vcnt shouldn't be used here since
it may not be accurate in cases of both cloned bio or bio cloned
from, but bio_segments() is a bit expensive, and bi_vcnt is still
the biggest number, so the approach should work.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-merge.c

index ba99351c0f58898cb83bd336299c773230e9e73f..b3ac40aef46b317c5a432a92ba9b40c8e1942504 100644 (file)
@@ -99,16 +99,17 @@ void blk_recount_segments(struct request_queue *q, struct bio *bio)
 {
        bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE,
                        &q->queue_flags);
+       bool merge_not_need = bio->bi_vcnt < queue_max_segments(q);
 
        if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) &&
-                       bio->bi_vcnt < queue_max_segments(q))
+                       merge_not_need)
                bio->bi_phys_segments = bio->bi_vcnt;
        else {
                struct bio *nxt = bio->bi_next;
 
                bio->bi_next = NULL;
                bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio,
-                               no_sg_merge);
+                               no_sg_merge && merge_not_need);
                bio->bi_next = nxt;
        }