aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2007-10-19 17:38:57 -0400
committerAlasdair G Kergon <agk@redhat.com>2007-10-19 21:01:13 -0400
commit9934a8bea2fc67e6f07d74304eca2a91d251bfe8 (patch)
treee2ea4b65a1fa4ad8d2a2dd8b755a7abaf91849c4 /drivers
parentd336416ff1e6f7715f6dcb3b4e3e60626e406dd0 (diff)
dm crypt: use per device singlethread workqueues
Use a separate single-threaded workqueue for each crypt device instead of one global workqueue. Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-crypt.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 3fa3b24947da..126ed21e6b17 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -80,6 +80,7 @@ struct crypt_config {
80 mempool_t *page_pool; 80 mempool_t *page_pool;
81 struct bio_set *bs; 81 struct bio_set *bs;
82 82
83 struct workqueue_struct *queue;
83 /* 84 /*
84 * crypto related data 85 * crypto related data
85 */ 86 */
@@ -480,13 +481,14 @@ static void dec_pending(struct dm_crypt_io *io, int error)
480 * Needed because it would be very unwise to do decryption in an 481 * Needed because it would be very unwise to do decryption in an
481 * interrupt context. 482 * interrupt context.
482 */ 483 */
483static struct workqueue_struct *_kcryptd_workqueue;
484static void kcryptd_do_work(struct work_struct *work); 484static void kcryptd_do_work(struct work_struct *work);
485 485
486static void kcryptd_queue_io(struct dm_crypt_io *io) 486static void kcryptd_queue_io(struct dm_crypt_io *io)
487{ 487{
488 struct crypt_config *cc = io->target->private;
489
488 INIT_WORK(&io->work, kcryptd_do_work); 490 INIT_WORK(&io->work, kcryptd_do_work);
489 queue_work(_kcryptd_workqueue, &io->work); 491 queue_work(cc->queue, &io->work);
490} 492}
491 493
492static void crypt_endio(struct bio *clone, int error) 494static void crypt_endio(struct bio *clone, int error)
@@ -868,9 +870,17 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
868 } else 870 } else
869 cc->iv_mode = NULL; 871 cc->iv_mode = NULL;
870 872
873 cc->queue = create_singlethread_workqueue("kcryptd");
874 if (!cc->queue) {
875 ti->error = "Couldn't create kcryptd queue";
876 goto bad_queue;
877 }
878
871 ti->private = cc; 879 ti->private = cc;
872 return 0; 880 return 0;
873 881
882bad_queue:
883 kfree(cc->iv_mode);
874bad_iv_mode: 884bad_iv_mode:
875 dm_put_device(ti, cc->dev); 885 dm_put_device(ti, cc->dev);
876bad5: 886bad5:
@@ -895,7 +905,7 @@ static void crypt_dtr(struct dm_target *ti)
895{ 905{
896 struct crypt_config *cc = (struct crypt_config *) ti->private; 906 struct crypt_config *cc = (struct crypt_config *) ti->private;
897 907
898 flush_workqueue(_kcryptd_workqueue); 908 destroy_workqueue(cc->queue);
899 909
900 bioset_free(cc->bs); 910 bioset_free(cc->bs);
901 mempool_destroy(cc->page_pool); 911 mempool_destroy(cc->page_pool);
@@ -1040,25 +1050,12 @@ static int __init dm_crypt_init(void)
1040 if (!_crypt_io_pool) 1050 if (!_crypt_io_pool)
1041 return -ENOMEM; 1051 return -ENOMEM;
1042 1052
1043 _kcryptd_workqueue = create_workqueue("kcryptd");
1044 if (!_kcryptd_workqueue) {
1045 r = -ENOMEM;
1046 DMERR("couldn't create kcryptd");
1047 goto bad1;
1048 }
1049
1050 r = dm_register_target(&crypt_target); 1053 r = dm_register_target(&crypt_target);
1051 if (r < 0) { 1054 if (r < 0) {
1052 DMERR("register failed %d", r); 1055 DMERR("register failed %d", r);
1053 goto bad2; 1056 kmem_cache_destroy(_crypt_io_pool);
1054 } 1057 }
1055 1058
1056 return 0;
1057
1058bad2:
1059 destroy_workqueue(_kcryptd_workqueue);
1060bad1:
1061 kmem_cache_destroy(_crypt_io_pool);
1062 return r; 1059 return r;
1063} 1060}
1064 1061
@@ -1069,7 +1066,6 @@ static void __exit dm_crypt_exit(void)
1069 if (r < 0) 1066 if (r < 0)
1070 DMERR("unregister failed %d", r); 1067 DMERR("unregister failed %d", r);
1071 1068
1072 destroy_workqueue(_kcryptd_workqueue);
1073 kmem_cache_destroy(_crypt_io_pool); 1069 kmem_cache_destroy(_crypt_io_pool);
1074} 1070}
1075 1071