diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2012-12-21 15:23:38 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-12-21 15:23:38 -0500 |
commit | e42c3f914da79102c54a7002329a086790c15327 (patch) | |
tree | 1679b19150c578bc34bc041c203999563c30634c /drivers | |
parent | 39cf0ed27ec70626e416c2f4780ea0449d405941 (diff) |
dm verity: use per_bio_data
Replace io_mempool with per_bio_data in dm-verity.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-verity.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c index 9e7328bb4030..78f349894b24 100644 --- a/drivers/md/dm-verity.c +++ b/drivers/md/dm-verity.c | |||
@@ -55,7 +55,6 @@ struct dm_verity { | |||
55 | unsigned shash_descsize;/* the size of temporary space for crypto */ | 55 | unsigned shash_descsize;/* the size of temporary space for crypto */ |
56 | int hash_failed; /* set to 1 if hash of any block failed */ | 56 | int hash_failed; /* set to 1 if hash of any block failed */ |
57 | 57 | ||
58 | mempool_t *io_mempool; /* mempool of struct dm_verity_io */ | ||
59 | mempool_t *vec_mempool; /* mempool of bio vector */ | 58 | mempool_t *vec_mempool; /* mempool of bio vector */ |
60 | 59 | ||
61 | struct workqueue_struct *verify_wq; | 60 | struct workqueue_struct *verify_wq; |
@@ -66,7 +65,6 @@ struct dm_verity { | |||
66 | 65 | ||
67 | struct dm_verity_io { | 66 | struct dm_verity_io { |
68 | struct dm_verity *v; | 67 | struct dm_verity *v; |
69 | struct bio *bio; | ||
70 | 68 | ||
71 | /* original values of bio->bi_end_io and bio->bi_private */ | 69 | /* original values of bio->bi_end_io and bio->bi_private */ |
72 | bio_end_io_t *orig_bi_end_io; | 70 | bio_end_io_t *orig_bi_end_io; |
@@ -389,8 +387,8 @@ test_block_hash: | |||
389 | */ | 387 | */ |
390 | static void verity_finish_io(struct dm_verity_io *io, int error) | 388 | static void verity_finish_io(struct dm_verity_io *io, int error) |
391 | { | 389 | { |
392 | struct bio *bio = io->bio; | ||
393 | struct dm_verity *v = io->v; | 390 | struct dm_verity *v = io->v; |
391 | struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_bio_data_size); | ||
394 | 392 | ||
395 | bio->bi_end_io = io->orig_bi_end_io; | 393 | bio->bi_end_io = io->orig_bi_end_io; |
396 | bio->bi_private = io->orig_bi_private; | 394 | bio->bi_private = io->orig_bi_private; |
@@ -398,8 +396,6 @@ static void verity_finish_io(struct dm_verity_io *io, int error) | |||
398 | if (io->io_vec != io->io_vec_inline) | 396 | if (io->io_vec != io->io_vec_inline) |
399 | mempool_free(io->io_vec, v->vec_mempool); | 397 | mempool_free(io->io_vec, v->vec_mempool); |
400 | 398 | ||
401 | mempool_free(io, v->io_mempool); | ||
402 | |||
403 | bio_endio(bio, error); | 399 | bio_endio(bio, error); |
404 | } | 400 | } |
405 | 401 | ||
@@ -486,9 +482,8 @@ static int verity_map(struct dm_target *ti, struct bio *bio, | |||
486 | if (bio_data_dir(bio) == WRITE) | 482 | if (bio_data_dir(bio) == WRITE) |
487 | return -EIO; | 483 | return -EIO; |
488 | 484 | ||
489 | io = mempool_alloc(v->io_mempool, GFP_NOIO); | 485 | io = dm_per_bio_data(bio, ti->per_bio_data_size); |
490 | io->v = v; | 486 | io->v = v; |
491 | io->bio = bio; | ||
492 | io->orig_bi_end_io = bio->bi_end_io; | 487 | io->orig_bi_end_io = bio->bi_end_io; |
493 | io->orig_bi_private = bio->bi_private; | 488 | io->orig_bi_private = bio->bi_private; |
494 | io->block = bio->bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT); | 489 | io->block = bio->bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT); |
@@ -610,9 +605,6 @@ static void verity_dtr(struct dm_target *ti) | |||
610 | if (v->vec_mempool) | 605 | if (v->vec_mempool) |
611 | mempool_destroy(v->vec_mempool); | 606 | mempool_destroy(v->vec_mempool); |
612 | 607 | ||
613 | if (v->io_mempool) | ||
614 | mempool_destroy(v->io_mempool); | ||
615 | |||
616 | if (v->bufio) | 608 | if (v->bufio) |
617 | dm_bufio_client_destroy(v->bufio); | 609 | dm_bufio_client_destroy(v->bufio); |
618 | 610 | ||
@@ -841,13 +833,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
841 | goto bad; | 833 | goto bad; |
842 | } | 834 | } |
843 | 835 | ||
844 | v->io_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE, | 836 | ti->per_bio_data_size = roundup(sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2, __alignof__(struct dm_verity_io)); |
845 | sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2); | ||
846 | if (!v->io_mempool) { | ||
847 | ti->error = "Cannot allocate io mempool"; | ||
848 | r = -ENOMEM; | ||
849 | goto bad; | ||
850 | } | ||
851 | 837 | ||
852 | v->vec_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE, | 838 | v->vec_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE, |
853 | BIO_MAX_PAGES * sizeof(struct bio_vec)); | 839 | BIO_MAX_PAGES * sizeof(struct bio_vec)); |
@@ -875,7 +861,7 @@ bad: | |||
875 | 861 | ||
876 | static struct target_type verity_target = { | 862 | static struct target_type verity_target = { |
877 | .name = "verity", | 863 | .name = "verity", |
878 | .version = {1, 0, 0}, | 864 | .version = {1, 1, 0}, |
879 | .module = THIS_MODULE, | 865 | .module = THIS_MODULE, |
880 | .ctr = verity_ctr, | 866 | .ctr = verity_ctr, |
881 | .dtr = verity_dtr, | 867 | .dtr = verity_dtr, |