block: assign bi_bdev for cloned bios in blk_rq_prep_clone
PATCH 1/1 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 0b6e522cdc4a ("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.
--- block/blk-mq.c | 1 + 1 file changed, 1 insertion(+)
block/blk-mq.c +1 -0
@@ -2976,6 +2976,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src, bio =bio_clone_fast (bio_src, gfp_mask, bs);if (!bio) goto free_and_out; + bio->bi_bdev = rq->q->disk->part0;if (bio_ctr &&bio_ctr (bio, bio_src, data)) goto free_and_out;
Signature · 1 line
2.30.2
Quoted 9 lines · Christoph Hellwig
bio_clone_fast()sets the cloned bio to have the same ->bi_bdev as the source bio. This means that when request-based dm calledsetup_clone(), the cloned bio had its ->bi_bdev pointing to the dm device. After Commit0b6e522cdc4a("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.[...]
Applied, thanks!
[1/1] block: assign bi_bdev for cloned bios in blk_rq_prep_clone
commit: fd9f4e62a39f09a7c014d7415c2b9d1390aa0504
Best regards,
Signature · 1 line
Jens Axboe