dm: pass NULL bdev to bio_alloc_clone
authorMike Snitzer <snitzer@kernel.org>
Wed, 11 May 2022 13:38:38 +0000 (09:38 -0400)
committerMike Snitzer <snitzer@kernel.org>
Wed, 11 May 2022 17:58:52 +0000 (13:58 -0400)
commitca522482e3eafd005b8d4e8b1331c911505a58d5
tree6100fe0c0e96e040418dd62a388d6906219a30d8
parentd254c3699fddb671bc555f042c96ec033582ae72
dm: pass NULL bdev to bio_alloc_clone

Most DM targets will remap the clone bio passed to their ->map
function using bio_set_bdev(). So this change to pass NULL bdev to
bio_alloc_clone avoids clone-time work that sets up resources for a
bdev association that will not be used in practice (e.g. clone issued
to underlying device will not use DM device's blk-cgroups resources).

But clone->bi_bdev is still initialized following bio_alloc_clone to
preserve DM target expectations that clone->bi_bdev will be set.
Follow-up work is needed to audit DM targets to remove accesses to a
clone->bi_bdev that the target didn't initialize with bio_set_dev().

Depends-on: 7ecc56c62b27 ("block: allow passing a NULL bdev to bio_alloc_clone/bio_init_clone")
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm.c