summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-02-02 17:01:06 +0100
committerJens Axboe <axboe@kernel.dk>2022-02-04 07:43:18 -0700
commit56b4b5abcdab6daf71c5536fca2772f178590e06 (patch)
treef27fc9b4b4be99d2b82d0b545b323016b32f0691 /drivers/md/dm.c
parent3c4b455ef8acdacd0e5ecd33428d4f32f861637a (diff)
downloadlinux-stable-56b4b5abcdab6daf71c5536fca2772f178590e06.tar.gz
linux-stable-56b4b5abcdab6daf71c5536fca2772f178590e06.tar.bz2
linux-stable-56b4b5abcdab6daf71c5536fca2772f178590e06.zip
block: clone crypto and integrity data in __bio_clone_fast
__bio_clone_fast should also clone integrity and crypto data, as a clone without those is incomplete. Right now the only caller that can actually support crypto and integrity data (dm) does it manually for the one callchain that supports these, but we better do it properly in the core. Note that all callers except for the above mentioned one also don't need to handle failure at all, given that the integrity and crypto clones are based on mempool allocations that won't fail for sleeping allocations. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Snitzer <snitzer@redhat.com> Link: https://lore.kernel.org/r/20220202160109.108149-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 78df75f57288..0f8796159379 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -561,7 +561,12 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti,
tio = clone_to_tio(clone);
tio->inside_dm_io = false;
}
- __bio_clone_fast(&tio->clone, ci->bio);
+
+ if (__bio_clone_fast(&tio->clone, ci->bio, gfp_mask) < 0) {
+ if (ci->io->tio.io)
+ bio_put(&tio->clone);
+ return NULL;
+ }
tio->magic = DM_TIO_MAGIC;
tio->io = ci->io;
@@ -1196,31 +1201,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
sector_t sector, unsigned *len)
{
struct bio *bio = ci->bio, *clone;
- int r;
clone = alloc_tio(ci, ti, 0, len, GFP_NOIO);
-
- r = bio_crypt_clone(clone, bio, GFP_NOIO);
- if (r < 0)
- goto free_tio;
-
- if (bio_integrity(bio)) {
- struct dm_target_io *tio = clone_to_tio(clone);
-
- if (unlikely(!dm_target_has_integrity(tio->ti->type) &&
- !dm_target_passes_integrity(tio->ti->type))) {
- DMWARN("%s: the target %s doesn't support integrity data.",
- dm_device_name(tio->io->md),
- tio->ti->type->name);
- r = -EIO;
- goto free_tio;
- }
-
- r = bio_integrity_clone(clone, bio, GFP_NOIO);
- if (r < 0)
- goto free_tio;
- }
-
bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector));
clone->bi_iter.bi_size = to_bytes(*len);
@@ -1229,9 +1211,6 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
__map_bio(clone);
return 0;
-free_tio:
- free_tio(clone);
- return r;
}
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,