@@ -137,9 +137,9 @@ struct iv_elephant_private {
137
137
* and encrypts / decrypts at the same time.
138
138
*/
139
139
enum flags { DM_CRYPT_SUSPENDED , DM_CRYPT_KEY_VALID ,
140
- DM_CRYPT_SAME_CPU , DM_CRYPT_NO_OFFLOAD ,
141
- DM_CRYPT_NO_READ_WORKQUEUE , DM_CRYPT_NO_WRITE_WORKQUEUE ,
142
- DM_CRYPT_WRITE_INLINE };
140
+ DM_CRYPT_SAME_CPU , DM_CRYPT_HIGH_PRIORITY ,
141
+ DM_CRYPT_NO_OFFLOAD , DM_CRYPT_NO_READ_WORKQUEUE ,
142
+ DM_CRYPT_NO_WRITE_WORKQUEUE , DM_CRYPT_WRITE_INLINE };
143
143
144
144
enum cipher_flags {
145
145
CRYPT_MODE_INTEGRITY_AEAD , /* Use authenticated mode for cipher */
@@ -3134,7 +3134,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
3134
3134
struct crypt_config * cc = ti -> private ;
3135
3135
struct dm_arg_set as ;
3136
3136
static const struct dm_arg _args [] = {
3137
- {0 , 8 , "Invalid number of feature args" },
3137
+ {0 , 9 , "Invalid number of feature args" },
3138
3138
};
3139
3139
unsigned int opt_params , val ;
3140
3140
const char * opt_string , * sval ;
@@ -3161,6 +3161,8 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
3161
3161
3162
3162
else if (!strcasecmp (opt_string , "same_cpu_crypt" ))
3163
3163
set_bit (DM_CRYPT_SAME_CPU , & cc -> flags );
3164
+ else if (!strcasecmp (opt_string , "high_priority" ))
3165
+ set_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags );
3164
3166
3165
3167
else if (!strcasecmp (opt_string , "submit_from_crypt_cpus" ))
3166
3168
set_bit (DM_CRYPT_NO_OFFLOAD , & cc -> flags );
@@ -3232,6 +3234,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
3232
3234
const char * devname = dm_table_device_name (ti -> table );
3233
3235
int key_size ;
3234
3236
unsigned int align_mask ;
3237
+ unsigned int common_wq_flags ;
3235
3238
unsigned long long tmpll ;
3236
3239
int ret ;
3237
3240
size_t iv_size_padding , additional_req_size ;
@@ -3399,19 +3402,25 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
3399
3402
}
3400
3403
3401
3404
ret = - ENOMEM ;
3402
- cc -> io_queue = alloc_workqueue ("kcryptd_io/%s" , WQ_MEM_RECLAIM , 1 , devname );
3405
+ common_wq_flags = WQ_MEM_RECLAIM ;
3406
+ if (test_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags ))
3407
+ common_wq_flags |= WQ_HIGHPRI ;
3408
+
3409
+ cc -> io_queue = alloc_workqueue ("kcryptd_io/%s" , common_wq_flags , 1 , devname );
3403
3410
if (!cc -> io_queue ) {
3404
3411
ti -> error = "Couldn't create kcryptd io queue" ;
3405
3412
goto bad ;
3406
3413
}
3407
3414
3408
- if (test_bit (DM_CRYPT_SAME_CPU , & cc -> flags ))
3409
- cc -> crypt_queue = alloc_workqueue ("kcryptd/%s" , WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM ,
3415
+ if (test_bit (DM_CRYPT_SAME_CPU , & cc -> flags )) {
3416
+ cc -> crypt_queue = alloc_workqueue ("kcryptd/%s" ,
3417
+ common_wq_flags | WQ_CPU_INTENSIVE ,
3410
3418
1 , devname );
3411
- else
3419
+ } else {
3412
3420
cc -> crypt_queue = alloc_workqueue ("kcryptd/%s" ,
3413
- WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM | WQ_UNBOUND ,
3421
+ common_wq_flags | WQ_CPU_INTENSIVE | WQ_UNBOUND ,
3414
3422
num_online_cpus (), devname );
3423
+ }
3415
3424
if (!cc -> crypt_queue ) {
3416
3425
ti -> error = "Couldn't create kcryptd queue" ;
3417
3426
goto bad ;
@@ -3427,6 +3436,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
3427
3436
ti -> error = "Couldn't spawn write thread" ;
3428
3437
goto bad ;
3429
3438
}
3439
+ if (test_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags ))
3440
+ set_user_nice (cc -> write_thread , MIN_NICE );
3430
3441
3431
3442
ti -> num_flush_bios = 1 ;
3432
3443
ti -> limit_swap_bios = true;
@@ -3547,6 +3558,7 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
3547
3558
3548
3559
num_feature_args += !!ti -> num_discard_bios ;
3549
3560
num_feature_args += test_bit (DM_CRYPT_SAME_CPU , & cc -> flags );
3561
+ num_feature_args += test_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags );
3550
3562
num_feature_args += test_bit (DM_CRYPT_NO_OFFLOAD , & cc -> flags );
3551
3563
num_feature_args += test_bit (DM_CRYPT_NO_READ_WORKQUEUE , & cc -> flags );
3552
3564
num_feature_args += test_bit (DM_CRYPT_NO_WRITE_WORKQUEUE , & cc -> flags );
@@ -3560,6 +3572,8 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
3560
3572
DMEMIT (" allow_discards" );
3561
3573
if (test_bit (DM_CRYPT_SAME_CPU , & cc -> flags ))
3562
3574
DMEMIT (" same_cpu_crypt" );
3575
+ if (test_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags ))
3576
+ DMEMIT (" high_priority" );
3563
3577
if (test_bit (DM_CRYPT_NO_OFFLOAD , & cc -> flags ))
3564
3578
DMEMIT (" submit_from_crypt_cpus" );
3565
3579
if (test_bit (DM_CRYPT_NO_READ_WORKQUEUE , & cc -> flags ))
@@ -3579,6 +3593,7 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
3579
3593
DMEMIT_TARGET_NAME_VERSION (ti -> type );
3580
3594
DMEMIT (",allow_discards=%c" , ti -> num_discard_bios ? 'y' : 'n' );
3581
3595
DMEMIT (",same_cpu_crypt=%c" , test_bit (DM_CRYPT_SAME_CPU , & cc -> flags ) ? 'y' : 'n' );
3596
+ DMEMIT (",high_priority=%c" , test_bit (DM_CRYPT_HIGH_PRIORITY , & cc -> flags ) ? 'y' : 'n' );
3582
3597
DMEMIT (",submit_from_crypt_cpus=%c" , test_bit (DM_CRYPT_NO_OFFLOAD , & cc -> flags ) ?
3583
3598
'y' : 'n' );
3584
3599
DMEMIT (",no_read_workqueue=%c" , test_bit (DM_CRYPT_NO_READ_WORKQUEUE , & cc -> flags ) ?
@@ -3706,7 +3721,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
3706
3721
3707
3722
static struct target_type crypt_target = {
3708
3723
.name = "crypt" ,
3709
- .version = {1 , 25 , 0 },
3724
+ .version = {1 , 26 , 0 },
3710
3725
.module = THIS_MODULE ,
3711
3726
.ctr = crypt_ctr ,
3712
3727
.dtr = crypt_dtr ,
0 commit comments