Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e42c3f91 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon
Browse files

dm verity: use per_bio_data



Replace io_mempool with per_bio_data in dm-verity.

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 39cf0ed2
Loading
Loading
Loading
Loading
+4 −18
Original line number Original line Diff line number Diff line
@@ -55,7 +55,6 @@ struct dm_verity {
	unsigned shash_descsize;/* the size of temporary space for crypto */
	unsigned shash_descsize;/* the size of temporary space for crypto */
	int hash_failed;	/* set to 1 if hash of any block failed */
	int hash_failed;	/* set to 1 if hash of any block failed */


	mempool_t *io_mempool;	/* mempool of struct dm_verity_io */
	mempool_t *vec_mempool;	/* mempool of bio vector */
	mempool_t *vec_mempool;	/* mempool of bio vector */


	struct workqueue_struct *verify_wq;
	struct workqueue_struct *verify_wq;
@@ -66,7 +65,6 @@ struct dm_verity {


struct dm_verity_io {
struct dm_verity_io {
	struct dm_verity *v;
	struct dm_verity *v;
	struct bio *bio;


	/* original values of bio->bi_end_io and bio->bi_private */
	/* original values of bio->bi_end_io and bio->bi_private */
	bio_end_io_t *orig_bi_end_io;
	bio_end_io_t *orig_bi_end_io;
@@ -389,8 +387,8 @@ test_block_hash:
 */
 */
static void verity_finish_io(struct dm_verity_io *io, int error)
static void verity_finish_io(struct dm_verity_io *io, int error)
{
{
	struct bio *bio = io->bio;
	struct dm_verity *v = io->v;
	struct dm_verity *v = io->v;
	struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_bio_data_size);


	bio->bi_end_io = io->orig_bi_end_io;
	bio->bi_end_io = io->orig_bi_end_io;
	bio->bi_private = io->orig_bi_private;
	bio->bi_private = io->orig_bi_private;
@@ -398,8 +396,6 @@ static void verity_finish_io(struct dm_verity_io *io, int error)
	if (io->io_vec != io->io_vec_inline)
	if (io->io_vec != io->io_vec_inline)
		mempool_free(io->io_vec, v->vec_mempool);
		mempool_free(io->io_vec, v->vec_mempool);


	mempool_free(io, v->io_mempool);

	bio_endio(bio, error);
	bio_endio(bio, error);
}
}


@@ -486,9 +482,8 @@ static int verity_map(struct dm_target *ti, struct bio *bio,
	if (bio_data_dir(bio) == WRITE)
	if (bio_data_dir(bio) == WRITE)
		return -EIO;
		return -EIO;


	io = mempool_alloc(v->io_mempool, GFP_NOIO);
	io = dm_per_bio_data(bio, ti->per_bio_data_size);
	io->v = v;
	io->v = v;
	io->bio = bio;
	io->orig_bi_end_io = bio->bi_end_io;
	io->orig_bi_end_io = bio->bi_end_io;
	io->orig_bi_private = bio->bi_private;
	io->orig_bi_private = bio->bi_private;
	io->block = bio->bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT);
	io->block = bio->bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT);
@@ -610,9 +605,6 @@ static void verity_dtr(struct dm_target *ti)
	if (v->vec_mempool)
	if (v->vec_mempool)
		mempool_destroy(v->vec_mempool);
		mempool_destroy(v->vec_mempool);


	if (v->io_mempool)
		mempool_destroy(v->io_mempool);

	if (v->bufio)
	if (v->bufio)
		dm_bufio_client_destroy(v->bufio);
		dm_bufio_client_destroy(v->bufio);


@@ -841,13 +833,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
		goto bad;
		goto bad;
	}
	}


	v->io_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE,
	ti->per_bio_data_size = roundup(sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2, __alignof__(struct dm_verity_io));
	  sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2);
	if (!v->io_mempool) {
		ti->error = "Cannot allocate io mempool";
		r = -ENOMEM;
		goto bad;
	}


	v->vec_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE,
	v->vec_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE,
					BIO_MAX_PAGES * sizeof(struct bio_vec));
					BIO_MAX_PAGES * sizeof(struct bio_vec));
@@ -875,7 +861,7 @@ bad:


static struct target_type verity_target = {
static struct target_type verity_target = {
	.name		= "verity",
	.name		= "verity",
	.version	= {1, 0, 0},
	.version	= {1, 1, 0},
	.module		= THIS_MODULE,
	.module		= THIS_MODULE,
	.ctr		= verity_ctr,
	.ctr		= verity_ctr,
	.dtr		= verity_dtr,
	.dtr		= verity_dtr,