summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-02-02 19:01:01 +0300
committerJens Axboe <axboe@kernel.dk>2022-02-04 17:43:17 +0300
commitdc8e2021da71f6b2d5971f98ee3e528cf30c409c (patch)
tree63a92b35d171d57a5ca5f2e2051adcf790da73c8 /drivers/md
parent8eabf5d0a7bd9226d6cc25402dde67f372aae838 (diff)
downloadlinux-dc8e2021da71f6b2d5971f98ee3e528cf30c409c.tar.xz
dm: move cloning the bio into alloc_tio
Move the call to __bio_clone_fast and the assignment of ->len_ptr from the callers into alloc_tio to prepare for changes to the bio clone API. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Snitzer <snitzer@redhat.com> Link: https://lore.kernel.org/r/20220202160109.108149-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 2527b287ead0..90341b7fa580 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -545,7 +545,7 @@ static void free_io(struct mapped_device *md, struct dm_io *io)
}
static struct dm_target_io *alloc_tio(struct clone_info *ci, struct dm_target *ti,
- unsigned target_bio_nr, gfp_t gfp_mask)
+ unsigned target_bio_nr, unsigned *len, gfp_t gfp_mask)
{
struct dm_target_io *tio;
@@ -561,11 +561,13 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, struct dm_target *t
tio = clone_to_tio(clone);
tio->inside_dm_io = false;
}
+ __bio_clone_fast(&tio->clone, ci->bio);
tio->magic = DM_TIO_MAGIC;
tio->io = ci->io;
tio->ti = ti;
tio->target_bio_nr = target_bio_nr;
+ tio->len_ptr = len;
return tio;
}
@@ -1197,11 +1199,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
struct dm_target_io *tio;
int r;
- tio = alloc_tio(ci, ti, 0, GFP_NOIO);
- tio->len_ptr = len;
-
+ tio = alloc_tio(ci, ti, 0, len, GFP_NOIO);
clone = &tio->clone;
- __bio_clone_fast(clone, bio);
r = bio_crypt_clone(clone, bio, GFP_NOIO);
if (r < 0)
@@ -1236,7 +1235,8 @@ free_tio:
}
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
- struct dm_target *ti, unsigned num_bios)
+ struct dm_target *ti, unsigned num_bios,
+ unsigned *len)
{
struct dm_target_io *tio;
int try;
@@ -1245,7 +1245,7 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
return;
if (num_bios == 1) {
- tio = alloc_tio(ci, ti, 0, GFP_NOIO);
+ tio = alloc_tio(ci, ti, 0, len, GFP_NOIO);
bio_list_add(blist, &tio->clone);
return;
}
@@ -1257,7 +1257,8 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
if (try)
mutex_lock(&ci->io->md->table_devices_lock);
for (bio_nr = 0; bio_nr < num_bios; bio_nr++) {
- tio = alloc_tio(ci, ti, bio_nr, try ? GFP_NOIO : GFP_NOWAIT);
+ tio = alloc_tio(ci, ti, bio_nr, len,
+ try ? GFP_NOIO : GFP_NOWAIT);
if (!tio)
break;
@@ -1279,14 +1280,11 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti,
struct bio_list blist = BIO_EMPTY_LIST;
struct bio *clone;
- alloc_multiple_bios(&blist, ci, ti, num_bios);
+ alloc_multiple_bios(&blist, ci, ti, num_bios, len);
while ((clone = bio_list_pop(&blist))) {
struct dm_target_io *tio = clone_to_tio(clone);
- tio->len_ptr = len;
-
- __bio_clone_fast(clone, ci->bio);
if (len)
bio_setup_sector(clone, ci->sector, *len);
__map_bio(tio);