diff --git a/man/crypttab.xml b/man/crypttab.xml
index 3574ce00da..f0d8030e12 100644
--- a/man/crypttab.xml
+++ b/man/crypttab.xml
@@ -224,6 +224,26 @@
mode.
+
+
+
+ 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.
+ This requires kernel 4.0 or newer.
+
+
+
+
+
+
+ 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.
+ This requires kernel 4.0 or newer.
+
+
+
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);