]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: add same-cpu-crypt and submit-from-crypt-cpus options
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Mar 2019 05:04:06 +0000 (14:04 +0900)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Mar 2019 08:48:50 +0000 (09:48 +0100)
Closes #11946.

man/crypttab.xml
src/cryptsetup/cryptsetup.c
src/shared/crypt-util.h

index 3574ce00da55bdf36806058290e94c68fb63f008..f0d8030e12e9e62d6a6f7625fd78c5c57e2dc8a0 100644 (file)
         mode.</para></listitem>
       </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>
 
index c8a4f82f86911dec66cf95748c1479b26cf1bdec..a16ea1024bad9b2bf373f00add14d08e4fa6f57c 100644 (file)
@@ -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
index 8c86714aec6817c690cd119accfa91ed87ba1c01..bdc2d046ecc786e6a36b9e9e61845c05a9f446ef 100644 (file)
 #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);