block: do not reassig ->bi_bdev when partition remapping
There is no good reason to reassign ->bi_bdev when remapping the
partition-relative block number to the device wide one, as all the
information required by the drivers comes from the gendisk anyway.
Keeping the original ->bi_bdev alive will allow to greatly simplify
the partition-away I/O accounting.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/block/blk-core.c b/block/blk-core.c
index 64f6902..1c1b97a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -752,7 +752,7 @@ static int blk_partition_remap(struct bio *bio)
bio->bi_iter.bi_sector -
p->bd_start_sect);
}
- bio->bi_bdev = bdev_whole(p);
+ bio_set_flag(bio, BIO_REMAPPED);
return 0;
}
@@ -817,7 +817,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
goto end_io;
if (unlikely(bio_check_eod(bio)))
goto end_io;
- if (bio->bi_bdev->bd_partno && unlikely(blk_partition_remap(bio)))
+ if (bio->bi_bdev->bd_partno && !bio_flagged(bio, BIO_REMAPPED) &&
+ unlikely(blk_partition_remap(bio)))
goto end_io;
/*