diff options
author | Christoph Hellwig <hch@lst.de> | 2022-02-02 17:00:59 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-02-04 07:43:17 -0700 |
commit | b1bee79237ce0ab43ef7fe66aa6e5c4783165012 (patch) | |
tree | 6414fc086dea0f438b7f8ff1d219daac12aaf4a0 /drivers/md/dm.c | |
parent | 6c23f0bd7f16d88c774db37b30c5da82811c41be (diff) |
dm: fold clone_bio into __clone_and_map_data_bio
Fold clone_bio into its only caller to prepare for refactoring.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Link: https://lore.kernel.org/r/20220202160109.108149-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 5543e18f3c3b..9384d250a3e4 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -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) { |