diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2015-02-13 08:27:08 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-02-16 11:11:15 -0500 |
commit | 0f5d8e6ee758f7023e4353cca75d785b2d4f6abe (patch) | |
tree | 836041a22c3b5f5eb6151f27b7b0dec1714ac5fd | |
parent | dc2676210c425ee8e5cb1bec5bc84d004ddf4179 (diff) |
dm crypt: add 'submit_from_crypt_cpus' option
Make it possible to disable offloading writes by setting the optional
'submit_from_crypt_cpus' table argument.
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 IO context.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r-- | Documentation/device-mapper/dm-crypt.txt | 10 | ||||
-rw-r--r-- | drivers/md/dm-crypt.c | 16 |
2 files changed, 23 insertions, 3 deletions
diff --git a/Documentation/device-mapper/dm-crypt.txt b/Documentation/device-mapper/dm-crypt.txt index 571f24ffc91c..ad697781f9ac 100644 --- a/Documentation/device-mapper/dm-crypt.txt +++ b/Documentation/device-mapper/dm-crypt.txt | |||
@@ -51,7 +51,7 @@ Parameters: <cipher> <key> <iv_offset> <device path> \ | |||
51 | Otherwise #opt_params is the number of following arguments. | 51 | Otherwise #opt_params is the number of following arguments. |
52 | 52 | ||
53 | Example of optional parameters section: | 53 | Example of optional parameters section: |
54 | 2 allow_discards same_cpu_crypt | 54 | 3 allow_discards same_cpu_crypt submit_from_crypt_cpus |
55 | 55 | ||
56 | allow_discards | 56 | allow_discards |
57 | Block discard requests (a.k.a. TRIM) are passed through the crypt device. | 57 | Block discard requests (a.k.a. TRIM) are passed through the crypt device. |
@@ -68,6 +68,14 @@ same_cpu_crypt | |||
68 | The default is to use an unbound workqueue so that encryption work | 68 | The default is to use an unbound workqueue so that encryption work |
69 | is automatically balanced between available CPUs. | 69 | is automatically balanced between available CPUs. |
70 | 70 | ||
71 | submit_from_crypt_cpus | ||
72 | Disable offloading writes to a separate thread after encryption. | ||
73 | There are some situations where offloading write bios from the | ||
74 | encryption threads to a single thread degrades performance | ||
75 | significantly. The default is to offload write bios to the same | ||
76 | thread because it benefits CFQ to have writes submitted using the | ||
77 | same context. | ||
78 | |||
71 | Example scripts | 79 | Example scripts |
72 | =============== | 80 | =============== |
73 | LUKS (Linux Unified Key Setup) is now the preferred way to set up disk | 81 | LUKS (Linux Unified Key Setup) is now the preferred way to set up disk |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 8c0e36b1d0ed..4519a7c0098c 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -110,7 +110,8 @@ struct iv_tcw_private { | |||
110 | * Crypt: maps a linear range of a block device | 110 | * Crypt: maps a linear range of a block device |
111 | * and encrypts / decrypts at the same time. | 111 | * and encrypts / decrypts at the same time. |
112 | */ | 112 | */ |
113 | enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, DM_CRYPT_SAME_CPU }; | 113 | enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, |
114 | DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD }; | ||
114 | 115 | ||
115 | /* | 116 | /* |
116 | * The fields in here must be read only after initialization. | 117 | * The fields in here must be read only after initialization. |
@@ -1239,6 +1240,11 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async) | |||
1239 | 1240 | ||
1240 | clone->bi_iter.bi_sector = cc->start + io->sector; | 1241 | clone->bi_iter.bi_sector = cc->start + io->sector; |
1241 | 1242 | ||
1243 | if (likely(!async) && test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags)) { | ||
1244 | generic_make_request(clone); | ||
1245 | return; | ||
1246 | } | ||
1247 | |||
1242 | spin_lock_irqsave(&cc->write_thread_wait.lock, flags); | 1248 | spin_lock_irqsave(&cc->write_thread_wait.lock, flags); |
1243 | list_add_tail(&io->list, &cc->write_thread_list); | 1249 | list_add_tail(&io->list, &cc->write_thread_list); |
1244 | wake_up_locked(&cc->write_thread_wait); | 1250 | wake_up_locked(&cc->write_thread_wait); |
@@ -1693,7 +1699,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1693 | char dummy; | 1699 | char dummy; |
1694 | 1700 | ||
1695 | static struct dm_arg _args[] = { | 1701 | static struct dm_arg _args[] = { |
1696 | {0, 2, "Invalid number of feature args"}, | 1702 | {0, 3, "Invalid number of feature args"}, |
1697 | }; | 1703 | }; |
1698 | 1704 | ||
1699 | if (argc < 5) { | 1705 | if (argc < 5) { |
@@ -1802,6 +1808,9 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1802 | else if (!strcasecmp(opt_string, "same_cpu_crypt")) | 1808 | else if (!strcasecmp(opt_string, "same_cpu_crypt")) |
1803 | set_bit(DM_CRYPT_SAME_CPU, &cc->flags); | 1809 | set_bit(DM_CRYPT_SAME_CPU, &cc->flags); |
1804 | 1810 | ||
1811 | else if (!strcasecmp(opt_string, "submit_from_crypt_cpus")) | ||
1812 | set_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags); | ||
1813 | |||
1805 | else { | 1814 | else { |
1806 | ti->error = "Invalid feature arguments"; | 1815 | ti->error = "Invalid feature arguments"; |
1807 | goto bad; | 1816 | goto bad; |
@@ -1905,12 +1914,15 @@ static void crypt_status(struct dm_target *ti, status_type_t type, | |||
1905 | 1914 | ||
1906 | num_feature_args += !!ti->num_discard_bios; | 1915 | num_feature_args += !!ti->num_discard_bios; |
1907 | num_feature_args += test_bit(DM_CRYPT_SAME_CPU, &cc->flags); | 1916 | num_feature_args += test_bit(DM_CRYPT_SAME_CPU, &cc->flags); |
1917 | num_feature_args += test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags); | ||
1908 | if (num_feature_args) { | 1918 | if (num_feature_args) { |
1909 | DMEMIT(" %d", num_feature_args); | 1919 | DMEMIT(" %d", num_feature_args); |
1910 | if (ti->num_discard_bios) | 1920 | if (ti->num_discard_bios) |
1911 | DMEMIT(" allow_discards"); | 1921 | DMEMIT(" allow_discards"); |
1912 | if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags)) | 1922 | if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags)) |
1913 | DMEMIT(" same_cpu_crypt"); | 1923 | DMEMIT(" same_cpu_crypt"); |
1924 | if (test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags)) | ||
1925 | DMEMIT(" submit_from_crypt_cpus"); | ||
1914 | } | 1926 | } |
1915 | 1927 | ||
1916 | break; | 1928 | break; |