|
47 | 47 |
|
48 | 48 | #define DM_MSG_PREFIX "crypt"
|
49 | 49 |
|
| 50 | +static DEFINE_IDA(workqueue_ida); |
| 51 | + |
50 | 52 | /*
|
51 | 53 | * context holding the current state of a multi-part conversion
|
52 | 54 | */
|
@@ -184,6 +186,7 @@ struct crypt_config {
|
184 | 186 | struct crypto_aead **tfms_aead;
|
185 | 187 | } cipher_tfm;
|
186 | 188 | unsigned int tfms_count;
|
| 189 | + int workqueue_id; |
187 | 190 | unsigned long cipher_flags;
|
188 | 191 |
|
189 | 192 | /*
|
@@ -2771,6 +2774,9 @@ static void crypt_dtr(struct dm_target *ti)
|
2771 | 2774 | if (cc->crypt_queue)
|
2772 | 2775 | destroy_workqueue(cc->crypt_queue);
|
2773 | 2776 |
|
| 2777 | + if (cc->workqueue_id) |
| 2778 | + ida_free(&workqueue_ida, cc->workqueue_id); |
| 2779 | + |
2774 | 2780 | crypt_free_tfms(cc);
|
2775 | 2781 |
|
2776 | 2782 | bioset_exit(&cc->bs);
|
@@ -3232,7 +3238,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
|
3232 | 3238 | {
|
3233 | 3239 | struct crypt_config *cc;
|
3234 | 3240 | const char *devname = dm_table_device_name(ti->table);
|
3235 |
| - int key_size; |
| 3241 | + int key_size, wq_id; |
3236 | 3242 | unsigned int align_mask;
|
3237 | 3243 | unsigned int common_wq_flags;
|
3238 | 3244 | unsigned long long tmpll;
|
@@ -3401,25 +3407,33 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
|
3401 | 3407 | cc->tag_pool_max_sectors <<= cc->sector_shift;
|
3402 | 3408 | }
|
3403 | 3409 |
|
| 3410 | + wq_id = ida_alloc_min(&workqueue_ida, 1, GFP_KERNEL); |
| 3411 | + if (wq_id < 0) { |
| 3412 | + ti->error = "Couldn't get workqueue id"; |
| 3413 | + ret = wq_id; |
| 3414 | + goto bad; |
| 3415 | + } |
| 3416 | + cc->workqueue_id = wq_id; |
| 3417 | + |
3404 | 3418 | ret = -ENOMEM;
|
3405 |
| - common_wq_flags = WQ_MEM_RECLAIM; |
| 3419 | + common_wq_flags = WQ_MEM_RECLAIM | WQ_SYSFS; |
3406 | 3420 | if (test_bit(DM_CRYPT_HIGH_PRIORITY, &cc->flags))
|
3407 | 3421 | common_wq_flags |= WQ_HIGHPRI;
|
3408 | 3422 |
|
3409 |
| - cc->io_queue = alloc_workqueue("kcryptd_io/%s", common_wq_flags, 1, devname); |
| 3423 | + cc->io_queue = alloc_workqueue("kcryptd_io-%s-%d", common_wq_flags, 1, devname, wq_id); |
3410 | 3424 | if (!cc->io_queue) {
|
3411 | 3425 | ti->error = "Couldn't create kcryptd io queue";
|
3412 | 3426 | goto bad;
|
3413 | 3427 | }
|
3414 | 3428 |
|
3415 | 3429 | if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags)) {
|
3416 |
| - cc->crypt_queue = alloc_workqueue("kcryptd/%s", |
| 3430 | + cc->crypt_queue = alloc_workqueue("kcryptd-%s-%d", |
3417 | 3431 | common_wq_flags | WQ_CPU_INTENSIVE,
|
3418 |
| - 1, devname); |
| 3432 | + 1, devname, wq_id); |
3419 | 3433 | } else {
|
3420 |
| - cc->crypt_queue = alloc_workqueue("kcryptd/%s", |
| 3434 | + cc->crypt_queue = alloc_workqueue("kcryptd-%s-%d", |
3421 | 3435 | common_wq_flags | WQ_CPU_INTENSIVE | WQ_UNBOUND,
|
3422 |
| - num_online_cpus(), devname); |
| 3436 | + num_online_cpus(), devname, wq_id); |
3423 | 3437 | }
|
3424 | 3438 | if (!cc->crypt_queue) {
|
3425 | 3439 | ti->error = "Couldn't create kcryptd queue";
|
|
0 commit comments