提交 dc8e2021 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

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: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NMike Snitzer <snitzer@redhat.com>
Link: https://lore.kernel.org/r/20220202160109.108149-6-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 8eabf5d0
...@@ -545,7 +545,7 @@ static void free_io(struct mapped_device *md, struct dm_io *io) ...@@ -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, 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; struct dm_target_io *tio;
...@@ -561,11 +561,13 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, struct dm_target *t ...@@ -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 = clone_to_tio(clone);
tio->inside_dm_io = false; tio->inside_dm_io = false;
} }
__bio_clone_fast(&tio->clone, ci->bio);
tio->magic = DM_TIO_MAGIC; tio->magic = DM_TIO_MAGIC;
tio->io = ci->io; tio->io = ci->io;
tio->ti = ti; tio->ti = ti;
tio->target_bio_nr = target_bio_nr; tio->target_bio_nr = target_bio_nr;
tio->len_ptr = len;
return tio; return tio;
} }
...@@ -1197,11 +1199,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti, ...@@ -1197,11 +1199,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
struct dm_target_io *tio; struct dm_target_io *tio;
int r; int r;
tio = alloc_tio(ci, ti, 0, GFP_NOIO); tio = alloc_tio(ci, ti, 0, len, GFP_NOIO);
tio->len_ptr = len;
clone = &tio->clone; clone = &tio->clone;
__bio_clone_fast(clone, bio);
r = bio_crypt_clone(clone, bio, GFP_NOIO); r = bio_crypt_clone(clone, bio, GFP_NOIO);
if (r < 0) if (r < 0)
...@@ -1236,7 +1235,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti, ...@@ -1236,7 +1235,8 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
} }
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, 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; struct dm_target_io *tio;
int try; int try;
...@@ -1245,7 +1245,7 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, ...@@ -1245,7 +1245,7 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
return; return;
if (num_bios == 1) { 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); bio_list_add(blist, &tio->clone);
return; return;
} }
...@@ -1257,7 +1257,8 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, ...@@ -1257,7 +1257,8 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
if (try) if (try)
mutex_lock(&ci->io->md->table_devices_lock); mutex_lock(&ci->io->md->table_devices_lock);
for (bio_nr = 0; bio_nr < num_bios; bio_nr++) { 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) if (!tio)
break; break;
...@@ -1279,14 +1280,11 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, ...@@ -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_list blist = BIO_EMPTY_LIST;
struct bio *clone; 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))) { while ((clone = bio_list_pop(&blist))) {
struct dm_target_io *tio = clone_to_tio(clone); struct dm_target_io *tio = clone_to_tio(clone);
tio->len_ptr = len;
__bio_clone_fast(clone, ci->bio);
if (len) if (len)
bio_setup_sector(clone, ci->sector, *len); bio_setup_sector(clone, ci->sector, *len);
__map_bio(tio); __map_bio(tio);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册