]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm: fold clone_bio into __clone_and_map_data_bio
authorChristoph Hellwig <hch@lst.de>
Wed, 2 Feb 2022 16:00:59 +0000 (17:00 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 4 Feb 2022 14:43:17 +0000 (07:43 -0700)
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>
drivers/md/dm.c

index 5543e18f3c3bcf8c065209a222da41b58a6c5cb8..9384d250a3e4e438f62ab50a7f6df5fcdeb40f73 100644 (file)
@@ -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)
 {