diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-03-11 14:04:06 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-03-13 09:48:50 +0100 |
commit | 2c65512ee7dede245b72110a12264094f475427c (patch) | |
tree | c7d238516fd000414d8fbe4ba2f9ac022e989ec8 | |
parent | 05044ebff90e4bc8bd5a546ba37e3a863c7b3dfc (diff) | |
download | systemd-2c65512ee7dede245b72110a12264094f475427c.tar.gz |
cryptsetup: add same-cpu-crypt and submit-from-crypt-cpus options
Closes #11946.
-rw-r--r-- | man/crypttab.xml | 20 | ||||
-rw-r--r-- | src/cryptsetup/cryptsetup.c | 12 | ||||
-rw-r--r-- | src/shared/crypt-util.h | 8 |
3 files changed, 40 insertions, 0 deletions
diff --git a/man/crypttab.xml b/man/crypttab.xml index 3574ce00da..f0d8030e12 100644 --- a/man/crypttab.xml +++ b/man/crypttab.xml @@ -225,6 +225,26 @@ </varlistentry> <varlistentry> + <term><option>same-cpu-crypt</option></term> + + <listitem><para>Perform encryption using the same cpu that IO was submitted on. The default is to use + an unbound workqueue so that encryption work is automatically balanced between available CPUs.</para> + <para>This requires kernel 4.0 or newer.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>submit-from-crypt-cpus</option></term> + + <listitem><para>Disable offloading writes to a separate thread after encryption. There are some + situations where offloading write bios from the encryption threads to a single thread degrades + performance significantly. The default is to offload write bios to the same thread because it benefits + CFQ to have writes submitted using the same context.</para> + <para>This requires kernel 4.0 or newer.</para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>skip=</option></term> <listitem><para>How many 512-byte sectors of the encrypted data to skip at the diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index c8a4f82f86..a16ea1024b 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -44,6 +44,8 @@ static unsigned arg_tries = 3; static bool arg_readonly = false; static bool arg_verify = false; static bool arg_discards = false; +static bool arg_same_cpu_crypt = false; +static bool arg_submit_from_crypt_cpus = false; static bool arg_tcrypt_hidden = false; static bool arg_tcrypt_system = false; #ifdef CRYPT_TCRYPT_VERA_MODES @@ -199,6 +201,10 @@ static int parse_one_option(const char *option) { arg_verify = true; else if (STR_IN_SET(option, "allow-discards", "discard")) arg_discards = true; + else if (streq(option, "same-cpu-crypt")) + arg_same_cpu_crypt = true; + else if (streq(option, "submit-from-crypt-cpus")) + arg_submit_from_crypt_cpus = true; else if (streq(option, "luks")) arg_type = ANY_LUKS; else if (streq(option, "tcrypt")) @@ -676,6 +682,12 @@ static int run(int argc, char *argv[]) { if (arg_discards) flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS; + if (arg_same_cpu_crypt) + flags |= CRYPT_ACTIVATE_SAME_CPU_CRYPT; + + if (arg_submit_from_crypt_cpus) + flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS; + if (arg_timeout == USEC_INFINITY) until = 0; else diff --git a/src/shared/crypt-util.h b/src/shared/crypt-util.h index 8c86714aec..bdc2d046ec 100644 --- a/src/shared/crypt-util.h +++ b/src/shared/crypt-util.h @@ -11,6 +11,14 @@ #define CRYPT_LUKS NULL #endif +#ifndef CRYPT_ACTIVATE_SAME_CPU_CRYPT +#define CRYPT_ACTIVATE_SAME_CPU_CRYPT (1 << 6) +#endif + +#ifndef CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS +#define CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS (1 << 7) +#endif + DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, crypt_free); void cryptsetup_log_glue(int level, const char *msg, void *usrptr); |