Skip to content

Commit fd9f4e6

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: assign bi_bdev for cloned bios in blk_rq_prep_clone
bio_clone_fast() sets the cloned bio to have the same ->bi_bdev as the source bio. This means that when request-based dm called setup_clone(), the cloned bio had its ->bi_bdev pointing to the dm device. After Commit 0b6e522 ("blk-mq: use ->bi_bdev for I/O accounting") __blk_account_io_start() started using the request's ->bio->bi_bdev for I/O accounting, if it was set. This caused IO going to the underlying devices to use the dm device for their I/O accounting. Set up the proper ->bi_bdev in blk_rq_prep_clone based on the whole device bdev for the queue the request is cloned onto. Fixes: 0b6e522 ("blk-mq: use ->bi_bdev for I/O accounting") Reported-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> [hch: the commit message is mostly from a different patch from Benjamin] Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com> Link: https://lore.kernel.org/r/20220118070444.1241739-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 850fd2a commit fd9f4e6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

block/blk-mq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,6 +2976,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
29762976
bio = bio_clone_fast(bio_src, gfp_mask, bs);
29772977
if (!bio)
29782978
goto free_and_out;
2979+
bio->bi_bdev = rq->q->disk->part0;
29792980

29802981
if (bio_ctr && bio_ctr(bio, bio_src, data))
29812982
goto free_and_out;

0 commit comments

Comments
 (0)