aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-crypt.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2015-02-13 08:27:08 -0500
committerMike Snitzer <snitzer@redhat.com>2015-02-16 11:11:15 -0500
commit0f5d8e6ee758f7023e4353cca75d785b2d4f6abe (patch)
tree836041a22c3b5f5eb6151f27b7b0dec1714ac5fd /drivers/md/dm-crypt.c
parentdc2676210c425ee8e5cb1bec5bc84d004ddf4179 (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>
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r--drivers/md/dm-crypt.c16
1 files changed, 14 insertions, 2 deletions
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 */
113enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, DM_CRYPT_SAME_CPU }; 113enum 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;