aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2015-02-13 08:23:09 -0500
committerMike Snitzer <snitzer@redhat.com>2015-02-16 11:10:59 -0500
commitf3396c58fd8442850e759843457d78b6ec3a9589 (patch)
treeb91199cf703350661510f5d2eafd98edd54ba11f /drivers/md
parent37527b869207ad4c208b1e13967d69b8bba1fbf9 (diff)
dm crypt: use unbound workqueue for request processing
Use unbound workqueue by default so that work is automatically balanced between available CPUs. The original behavior of encrypting using the same cpu that IO was submitted on can still be enabled by setting the optional 'same_cpu_crypt' table argument. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-crypt.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 08981be7baa1..5063c901c0f5 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -108,7 +108,7 @@ struct iv_tcw_private {
108 * Crypt: maps a linear range of a block device 108 * Crypt: maps a linear range of a block device
109 * and encrypts / decrypts at the same time. 109 * and encrypts / decrypts at the same time.
110 */ 110 */
111enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID }; 111enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, DM_CRYPT_SAME_CPU };
112 112
113/* 113/*
114 * The fields in here must be read only after initialization. 114 * The fields in here must be read only after initialization.
@@ -1688,7 +1688,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1688 char dummy; 1688 char dummy;
1689 1689
1690 static struct dm_arg _args[] = { 1690 static struct dm_arg _args[] = {
1691 {0, 1, "Invalid number of feature args"}, 1691 {0, 2, "Invalid number of feature args"},
1692 }; 1692 };
1693 1693
1694 if (argc < 5) { 1694 if (argc < 5) {
@@ -1788,15 +1788,23 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1788 if (ret) 1788 if (ret)
1789 goto bad; 1789 goto bad;
1790 1790
1791 opt_string = dm_shift_arg(&as); 1791 while (opt_params--) {
1792 opt_string = dm_shift_arg(&as);
1793 if (!opt_string) {
1794 ti->error = "Not enough feature arguments";
1795 goto bad;
1796 }
1792 1797
1793 if (opt_params == 1 && opt_string && 1798 if (!strcasecmp(opt_string, "allow_discards"))
1794 !strcasecmp(opt_string, "allow_discards")) 1799 ti->num_discard_bios = 1;
1795 ti->num_discard_bios = 1; 1800
1796 else if (opt_params) { 1801 else if (!strcasecmp(opt_string, "same_cpu_crypt"))
1797 ret = -EINVAL; 1802 set_bit(DM_CRYPT_SAME_CPU, &cc->flags);
1798 ti->error = "Invalid feature arguments"; 1803
1799 goto bad; 1804 else {
1805 ti->error = "Invalid feature arguments";
1806 goto bad;
1807 }
1800 } 1808 }
1801 } 1809 }
1802 1810
@@ -1807,8 +1815,11 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1807 goto bad; 1815 goto bad;
1808 } 1816 }
1809 1817
1810 cc->crypt_queue = alloc_workqueue("kcryptd", 1818 if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags))
1811 WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1); 1819 cc->crypt_queue = alloc_workqueue("kcryptd", WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
1820 else
1821 cc->crypt_queue = alloc_workqueue("kcryptd", WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM | WQ_UNBOUND,
1822 num_online_cpus());
1812 if (!cc->crypt_queue) { 1823 if (!cc->crypt_queue) {
1813 ti->error = "Couldn't create kcryptd queue"; 1824 ti->error = "Couldn't create kcryptd queue";
1814 goto bad; 1825 goto bad;
@@ -1860,6 +1871,7 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
1860{ 1871{
1861 struct crypt_config *cc = ti->private; 1872 struct crypt_config *cc = ti->private;
1862 unsigned i, sz = 0; 1873 unsigned i, sz = 0;
1874 int num_feature_args = 0;
1863 1875
1864 switch (type) { 1876 switch (type) {
1865 case STATUSTYPE_INFO: 1877 case STATUSTYPE_INFO:
@@ -1878,8 +1890,15 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
1878 DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset, 1890 DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset,
1879 cc->dev->name, (unsigned long long)cc->start); 1891 cc->dev->name, (unsigned long long)cc->start);
1880 1892
1881 if (ti->num_discard_bios) 1893 num_feature_args += !!ti->num_discard_bios;
1882 DMEMIT(" 1 allow_discards"); 1894 num_feature_args += test_bit(DM_CRYPT_SAME_CPU, &cc->flags);
1895 if (num_feature_args) {
1896 DMEMIT(" %d", num_feature_args);
1897 if (ti->num_discard_bios)
1898 DMEMIT(" allow_discards");
1899 if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags))
1900 DMEMIT(" same_cpu_crypt");
1901 }
1883 1902
1884 break; 1903 break;
1885 } 1904 }
@@ -1976,7 +1995,7 @@ static int crypt_iterate_devices(struct dm_target *ti,
1976 1995
1977static struct target_type crypt_target = { 1996static struct target_type crypt_target = {
1978 .name = "crypt", 1997 .name = "crypt",
1979 .version = {1, 13, 0}, 1998 .version = {1, 14, 0},
1980 .module = THIS_MODULE, 1999 .module = THIS_MODULE,
1981 .ctr = crypt_ctr, 2000 .ctr = crypt_ctr,
1982 .dtr = crypt_dtr, 2001 .dtr = crypt_dtr,