aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-crypt.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index fa1dba1d06f7..c29daf417aaf 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -120,7 +120,6 @@ struct crypt_config {
120 * pool for per bio private data, crypto requests and 120 * pool for per bio private data, crypto requests and
121 * encryption requeusts/buffer pages 121 * encryption requeusts/buffer pages
122 */ 122 */
123 mempool_t *io_pool;
124 mempool_t *req_pool; 123 mempool_t *req_pool;
125 mempool_t *page_pool; 124 mempool_t *page_pool;
126 struct bio_set *bs; 125 struct bio_set *bs;
@@ -173,8 +172,6 @@ struct crypt_config {
173 172
174#define MIN_IOS 16 173#define MIN_IOS 16
175 174
176static struct kmem_cache *_crypt_io_pool;
177
178static void clone_init(struct dm_crypt_io *, struct bio *); 175static void clone_init(struct dm_crypt_io *, struct bio *);
179static void kcryptd_queue_crypt(struct dm_crypt_io *io); 176static void kcryptd_queue_crypt(struct dm_crypt_io *io);
180static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmreq); 177static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmreq);
@@ -1056,8 +1053,6 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
1056 1053
1057 if (io->ctx.req) 1054 if (io->ctx.req)
1058 crypt_free_req(cc, io->ctx.req, base_bio); 1055 crypt_free_req(cc, io->ctx.req, base_bio);
1059 if (io != dm_per_bio_data(base_bio, cc->per_bio_data_size))
1060 mempool_free(io, cc->io_pool);
1061 1056
1062 bio_endio(base_bio, error); 1057 bio_endio(base_bio, error);
1063} 1058}
@@ -1445,8 +1440,6 @@ static void crypt_dtr(struct dm_target *ti)
1445 mempool_destroy(cc->page_pool); 1440 mempool_destroy(cc->page_pool);
1446 if (cc->req_pool) 1441 if (cc->req_pool)
1447 mempool_destroy(cc->req_pool); 1442 mempool_destroy(cc->req_pool);
1448 if (cc->io_pool)
1449 mempool_destroy(cc->io_pool);
1450 1443
1451 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) 1444 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
1452 cc->iv_gen_ops->dtr(cc); 1445 cc->iv_gen_ops->dtr(cc);
@@ -1660,13 +1653,6 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1660 if (ret < 0) 1653 if (ret < 0)
1661 goto bad; 1654 goto bad;
1662 1655
1663 ret = -ENOMEM;
1664 cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool);
1665 if (!cc->io_pool) {
1666 ti->error = "Cannot allocate crypt io mempool";
1667 goto bad;
1668 }
1669
1670 cc->dmreq_start = sizeof(struct ablkcipher_request); 1656 cc->dmreq_start = sizeof(struct ablkcipher_request);
1671 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc)); 1657 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc));
1672 cc->dmreq_start = ALIGN(cc->dmreq_start, __alignof__(struct dm_crypt_request)); 1658 cc->dmreq_start = ALIGN(cc->dmreq_start, __alignof__(struct dm_crypt_request));
@@ -1684,6 +1670,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1684 iv_size_padding = crypto_ablkcipher_alignmask(any_tfm(cc)); 1670 iv_size_padding = crypto_ablkcipher_alignmask(any_tfm(cc));
1685 } 1671 }
1686 1672
1673 ret = -ENOMEM;
1687 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start + 1674 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start +
1688 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size); 1675 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size);
1689 if (!cc->req_pool) { 1676 if (!cc->req_pool) {
@@ -1965,15 +1952,9 @@ static int __init dm_crypt_init(void)
1965{ 1952{
1966 int r; 1953 int r;
1967 1954
1968 _crypt_io_pool = KMEM_CACHE(dm_crypt_io, 0);
1969 if (!_crypt_io_pool)
1970 return -ENOMEM;
1971
1972 r = dm_register_target(&crypt_target); 1955 r = dm_register_target(&crypt_target);
1973 if (r < 0) { 1956 if (r < 0)
1974 DMERR("register failed %d", r); 1957 DMERR("register failed %d", r);
1975 kmem_cache_destroy(_crypt_io_pool);
1976 }
1977 1958
1978 return r; 1959 return r;
1979} 1960}
@@ -1981,7 +1962,6 @@ static int __init dm_crypt_init(void)
1981static void __exit dm_crypt_exit(void) 1962static void __exit dm_crypt_exit(void)
1982{ 1963{
1983 dm_unregister_target(&crypt_target); 1964 dm_unregister_target(&crypt_target);
1984 kmem_cache_destroy(_crypt_io_pool);
1985} 1965}
1986 1966
1987module_init(dm_crypt_init); 1967module_init(dm_crypt_init);