Commit b1bee792 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

dm: fold clone_bio into __clone_and_map_data_bio

Fold clone_bio into its only caller to prepare for refactoring.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMike Snitzer <snitzer@redhat.com>
Link: https://lore.kernel.org/r/20220202160109.108149-4-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6c23f0bd
......@@ -1190,17 +1190,22 @@ static void bio_setup_sector(struct bio *bio, sector_t sector, unsigned len)
/*
* Creates a bio that consists of range of complete bvecs.
*/
static int clone_bio(struct dm_target_io *tio, struct bio *bio,
sector_t sector, unsigned len)
static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
sector_t sector, unsigned *len)
{
struct bio *clone = &tio->clone;
struct bio *bio = ci->bio, *clone;
struct dm_target_io *tio;
int r;
tio = alloc_tio(ci, ti, 0, GFP_NOIO);
tio->len_ptr = len;
clone = &tio->clone;
__bio_clone_fast(clone, bio);
r = bio_crypt_clone(clone, bio, GFP_NOIO);
if (r < 0)
return r;
goto free_tio;
if (bio_integrity(bio)) {
if (unlikely(!dm_target_has_integrity(tio->ti->type) &&
......@@ -1208,21 +1213,26 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
DMWARN("%s: the target %s doesn't support integrity data.",
dm_device_name(tio->io->md),
tio->ti->type->name);
return -EIO;
r = -EIO;
goto free_tio;
}
r = bio_integrity_clone(clone, bio, GFP_NOIO);
if (r < 0)
return r;
goto free_tio;
}
bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector));
clone->bi_iter.bi_size = to_bytes(len);
clone->bi_iter.bi_size = to_bytes(*len);
if (bio_integrity(bio))
bio_integrity_trim(clone);
__map_bio(tio);
return 0;
free_tio:
free_tio(tio);
return r;
}
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
......@@ -1313,25 +1323,6 @@ static int __send_empty_flush(struct clone_info *ci)
return 0;
}
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;
struct dm_target_io *tio;
int r;
tio = alloc_tio(ci, ti, 0, GFP_NOIO);
tio->len_ptr = len;
r = clone_bio(tio, bio, sector, *len);
if (r < 0) {
free_tio(tio);
return r;
}
__map_bio(tio);
return 0;
}
static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment