summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan G. Underwood <jonathan.underwood@gmail.com>2020-12-22 20:04:52 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-30 15:24:12 +0100
commitdef3ea14df31ad827c7ef2af3b6ce96ca2e0ebcf (patch)
tree2ce07ef5da2665a0c779e77c12b5203804d178e8
parent90f7f6c5777e9e2a4990f299474f730459054bf4 (diff)
downloadsystemd-def3ea14df31ad827c7ef2af3b6ce96ca2e0ebcf.tar.gz
cryptsetup: add support for workqueue options
This commit adds support for disabling the read and write workqueues with the new crypttab options no-read-workqueue and no-write-workqueue. These correspond to the cryptsetup options --perf-no_read_workqueue and --perf-no_write_workqueue respectively. (cherry picked from commit 227acf0009bde2cd7f8bc371615b05e84137847d)
-rw-r--r--man/crypttab.xml19
-rw-r--r--src/cryptsetup/cryptsetup.c12
-rw-r--r--src/shared/crypt-util.h8
3 files changed, 39 insertions, 0 deletions
diff --git a/man/crypttab.xml b/man/crypttab.xml
index ee54499bfe..eb060c103e 100644
--- a/man/crypttab.xml
+++ b/man/crypttab.xml
@@ -273,6 +273,25 @@
</varlistentry>
<varlistentry>
+ <term><option>no-read-workqueue</option></term>
+
+ <listitem><para>Bypass dm-crypt internal workqueue and process read requests synchronously. The
+ default is to queue these requests and process them asynchronously.</para>
+
+ <para>This requires kernel 5.9 or newer.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>no-write-workqueue</option></term>
+
+ <listitem><para>Bypass dm-crypt internal workqueue and process write requests synchronously. The
+ default is to queue these requests and process them asynchronously.</para>
+
+ <para>This requires kernel 5.9 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 6d3f842dbe..12e32ebf05 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -55,6 +55,8 @@ 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_no_read_workqueue = false;
+static bool arg_no_write_workqueue = false;
static bool arg_tcrypt_hidden = false;
static bool arg_tcrypt_system = false;
static bool arg_tcrypt_veracrypt = false;
@@ -218,6 +220,10 @@ static int parse_one_option(const char *option) {
arg_same_cpu_crypt = true;
else if (streq(option, "submit-from-crypt-cpus"))
arg_submit_from_crypt_cpus = true;
+ else if (streq(option, "no-read-workqueue"))
+ arg_no_read_workqueue = true;
+ else if (streq(option, "no-write-workqueue"))
+ arg_no_write_workqueue = true;
else if (streq(option, "luks"))
arg_type = ANY_LUKS;
/* since cryptsetup 2.3.0 (Feb 2020) */
@@ -805,6 +811,12 @@ static uint32_t determine_flags(void) {
if (arg_submit_from_crypt_cpus)
flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS;
+ if (arg_no_read_workqueue)
+ flags |= CRYPT_ACTIVATE_NO_READ_WORKQUEUE;
+
+ if (arg_no_write_workqueue)
+ flags |= CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE;
+
#ifdef CRYPT_ACTIVATE_SERIALIZE_MEMORY_HARD_PBKDF
/* Try to decrease the risk of OOM event if memory hard key derivation function is in use */
/* https://gitlab.com/cryptsetup/cryptsetup/issues/446/ */
diff --git a/src/shared/crypt-util.h b/src/shared/crypt-util.h
index c25b11599c..ce44cd43e7 100644
--- a/src/shared/crypt-util.h
+++ b/src/shared/crypt-util.h
@@ -6,6 +6,14 @@
#include "macro.h"
+/* These next two are defined in libcryptsetup.h from cryptsetup version 2.3.4 forwards. */
+#ifndef CRYPT_ACTIVATE_NO_READ_WORKQUEUE
+#define CRYPT_ACTIVATE_NO_READ_WORKQUEUE (1 << 24)
+#endif
+#ifndef CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE
+#define CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE (1 << 25)
+#endif
+
DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, crypt_free);
void cryptsetup_log_glue(int level, const char *msg, void *usrptr);