Skip to content

Commit 3f868c0

Browse files
Christoph Hellwigaxboe
authored andcommitted
dm-crypt: remove clone_init
Just open code it next to the bio allocations, which saves a few lines of code, prepares for future changes and allows to remove the duplicate bi_opf assignment for the bio_clone_fast case in kcryptd_io_read. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 53db984 commit 3f868c0

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/md/dm-crypt.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static volatile unsigned long dm_crypt_pages_per_client;
234234
#define DM_CRYPT_MEMORY_PERCENT 2
235235
#define DM_CRYPT_MIN_PAGES_PER_CLIENT (BIO_MAX_VECS * 16)
236236

237-
static void clone_init(struct dm_crypt_io *, struct bio *);
237+
static void crypt_endio(struct bio *clone);
238238
static void kcryptd_queue_crypt(struct dm_crypt_io *io);
239239
static struct scatterlist *crypt_get_sg_data(struct crypt_config *cc,
240240
struct scatterlist *sg);
@@ -1673,7 +1673,10 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
16731673
mutex_lock(&cc->bio_alloc_lock);
16741674

16751675
clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, &cc->bs);
1676-
clone_init(io, clone);
1676+
clone->bi_private = io;
1677+
clone->bi_end_io = crypt_endio;
1678+
bio_set_dev(clone, cc->dev->bdev);
1679+
clone->bi_opf = io->base_bio->bi_opf;
16771680

16781681
remaining_size = size;
16791682

@@ -1826,16 +1829,6 @@ static void crypt_endio(struct bio *clone)
18261829
crypt_dec_pending(io);
18271830
}
18281831

1829-
static void clone_init(struct dm_crypt_io *io, struct bio *clone)
1830-
{
1831-
struct crypt_config *cc = io->cc;
1832-
1833-
clone->bi_private = io;
1834-
clone->bi_end_io = crypt_endio;
1835-
bio_set_dev(clone, cc->dev->bdev);
1836-
clone->bi_opf = io->base_bio->bi_opf;
1837-
}
1838-
18391832
static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
18401833
{
18411834
struct crypt_config *cc = io->cc;
@@ -1850,10 +1843,12 @@ static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
18501843
clone = bio_clone_fast(io->base_bio, gfp, &cc->bs);
18511844
if (!clone)
18521845
return 1;
1846+
clone->bi_private = io;
1847+
clone->bi_end_io = crypt_endio;
1848+
bio_set_dev(clone, cc->dev->bdev);
18531849

18541850
crypt_inc_pending(io);
18551851

1856-
clone_init(io, clone);
18571852
clone->bi_iter.bi_sector = cc->start + io->sector;
18581853

18591854
if (dm_crypt_integrity_io_alloc(io, clone)) {

0 commit comments

Comments
 (0)