]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
blk-integrity: consider entire bio list for merging
authorKeith Busch <kbusch@kernel.org>
Fri, 13 Sep 2024 18:28:49 +0000 (11:28 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Sep 2024 18:31:45 +0000 (12:31 -0600)
If a bio is merged to a request, the entire bio list is merged, so don't
temporarily detach it from its list when counting segments. In most
cases, bi_next will already be NULL, so detaching is usually a no-op.
But if the bio does have a list, the current code is miscounting the
segments for the resulting merge.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20240913182854.2445457-5-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-integrity.c

index afd101555d3cbd3506f6b295340cd3eefd001e95..84065691aaed0419cb8282c2bd32fa287442454d 100644 (file)
@@ -134,7 +134,6 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req,
                             struct bio *bio)
 {
        int nr_integrity_segs;
-       struct bio *next = bio->bi_next;
 
        if (blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL)
                return true;
@@ -145,10 +144,7 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req,
        if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags)
                return false;
 
-       bio->bi_next = NULL;
        nr_integrity_segs = blk_rq_count_integrity_sg(q, bio);
-       bio->bi_next = next;
-
        if (req->nr_integrity_segments + nr_integrity_segs >
            q->limits.max_integrity_segments)
                return false;