diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 13:16:46 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 13:16:46 -0400 |
| commit | 8357422d4bf33bc2c35884d4016c3fc9efbbc1d2 (patch) | |
| tree | 5779dfe36de828d3ef2dacfda48b7961cdc44525 | |
| parent | 1021a645344d4a77333e19e60d37b9343be0d7b7 (diff) | |
| parent | 959eb4e5592cc0b0b07db0ca30d2b1efd790020f (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
* git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm: (33 commits)
dm mpath: support discard
dm stripe: support discards
dm: split discard requests on target boundaries
dm stripe: optimize sector division
dm stripe: move sector translation to a function
dm: error return error for discards
dm delay: support discard
dm: zero silently drop discards
dm: use dm_target_offset macro
dm: factor out max_io_len_target_boundary
dm: use common __issue_target_request for flush and discard support
dm: linear support discard
dm crypt: simplify crypt_ctr
dm crypt: simplify crypt_config destruction logic
dm: allow autoloading of dm mod
dm: rename map_info flush_request to target_request_nr
dm ioctl: refactor dm_table_complete
dm snapshot: implement merge
dm: do not initialise full request queue when bio based
dm ioctl: make bio or request based device type immutable
...
| -rw-r--r-- | Documentation/devices.txt | 1 | ||||
| -rw-r--r-- | drivers/md/dm-crypt.c | 342 | ||||
| -rw-r--r-- | drivers/md/dm-delay.c | 6 | ||||
| -rw-r--r-- | drivers/md/dm-exception-store.c | 4 | ||||
| -rw-r--r-- | drivers/md/dm-exception-store.h | 3 | ||||
| -rw-r--r-- | drivers/md/dm-ioctl.c | 207 | ||||
| -rw-r--r-- | drivers/md/dm-linear.c | 3 | ||||
| -rw-r--r-- | drivers/md/dm-mpath.c | 11 | ||||
| -rw-r--r-- | drivers/md/dm-raid1.c | 2 | ||||
| -rw-r--r-- | drivers/md/dm-snap-persistent.c | 6 | ||||
| -rw-r--r-- | drivers/md/dm-snap.c | 62 | ||||
| -rw-r--r-- | drivers/md/dm-stripe.c | 87 | ||||
| -rw-r--r-- | drivers/md/dm-table.c | 99 | ||||
| -rw-r--r-- | drivers/md/dm-target.c | 5 | ||||
| -rw-r--r-- | drivers/md/dm-zero.c | 5 | ||||
| -rw-r--r-- | drivers/md/dm.c | 329 | ||||
| -rw-r--r-- | drivers/md/dm.h | 14 | ||||
| -rw-r--r-- | include/linux/device-mapper.h | 16 | ||||
| -rw-r--r-- | include/linux/dm-ioctl.h | 5 | ||||
| -rw-r--r-- | include/linux/miscdevice.h | 1 |
20 files changed, 822 insertions, 386 deletions
diff --git a/Documentation/devices.txt b/Documentation/devices.txt index f2da781705b2..d0d1df6cb5de 100644 --- a/Documentation/devices.txt +++ b/Documentation/devices.txt | |||
| @@ -445,6 +445,7 @@ Your cooperation is appreciated. | |||
| 445 | 233 = /dev/kmview View-OS A process with a view | 445 | 233 = /dev/kmview View-OS A process with a view |
| 446 | 234 = /dev/btrfs-control Btrfs control device | 446 | 234 = /dev/btrfs-control Btrfs control device |
| 447 | 235 = /dev/autofs Autofs control device | 447 | 235 = /dev/autofs Autofs control device |
| 448 | 236 = /dev/mapper/control Device-Mapper control device | ||
| 448 | 240-254 Reserved for local use | 449 | 240-254 Reserved for local use |
| 449 | 255 Reserved for MISC_DYNAMIC_MINOR | 450 | 255 Reserved for MISC_DYNAMIC_MINOR |
| 450 | 451 | ||
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 3bdbb6115702..368e8e98f705 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -107,11 +107,10 @@ struct crypt_config { | |||
| 107 | struct workqueue_struct *io_queue; | 107 | struct workqueue_struct *io_queue; |
| 108 | struct workqueue_struct *crypt_queue; | 108 | struct workqueue_struct *crypt_queue; |
| 109 | 109 | ||
| 110 | /* | 110 | char *cipher; |
| 111 | * crypto related data | 111 | char *cipher_mode; |
| 112 | */ | 112 | |
| 113 | struct crypt_iv_operations *iv_gen_ops; | 113 | struct crypt_iv_operations *iv_gen_ops; |
| 114 | char *iv_mode; | ||
| 115 | union { | 114 | union { |
| 116 | struct iv_essiv_private essiv; | 115 | struct iv_essiv_private essiv; |
| 117 | struct iv_benbi_private benbi; | 116 | struct iv_benbi_private benbi; |
| @@ -135,8 +134,6 @@ struct crypt_config { | |||
| 135 | unsigned int dmreq_start; | 134 | unsigned int dmreq_start; |
| 136 | struct ablkcipher_request *req; | 135 | struct ablkcipher_request *req; |
| 137 | 136 | ||
| 138 | char cipher[CRYPTO_MAX_ALG_NAME]; | ||
| 139 | char chainmode[CRYPTO_MAX_ALG_NAME]; | ||
| 140 | struct crypto_ablkcipher *tfm; | 137 | struct crypto_ablkcipher *tfm; |
| 141 | unsigned long flags; | 138 | unsigned long flags; |
| 142 | unsigned int key_size; | 139 | unsigned int key_size; |
| @@ -999,82 +996,135 @@ static int crypt_wipe_key(struct crypt_config *cc) | |||
| 999 | return crypto_ablkcipher_setkey(cc->tfm, cc->key, cc->key_size); | 996 | return crypto_ablkcipher_setkey(cc->tfm, cc->key, cc->key_size); |
| 1000 | } | 997 | } |
| 1001 | 998 | ||
| 1002 | /* | 999 | static void crypt_dtr(struct dm_target *ti) |
| 1003 | * Construct an encryption mapping: | ||
| 1004 | * <cipher> <key> <iv_offset> <dev_path> <start> | ||
| 1005 | */ | ||
| 1006 | static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | ||
| 1007 | { | 1000 | { |
| 1008 | struct crypt_config *cc; | 1001 | struct crypt_config *cc = ti->private; |
| 1009 | struct crypto_ablkcipher *tfm; | ||
| 1010 | char *tmp; | ||
| 1011 | char *cipher; | ||
| 1012 | char *chainmode; | ||
| 1013 | char *ivmode; | ||
| 1014 | char *ivopts; | ||
| 1015 | unsigned int key_size; | ||
| 1016 | unsigned long long tmpll; | ||
| 1017 | 1002 | ||
| 1018 | if (argc != 5) { | 1003 | ti->private = NULL; |
| 1019 | ti->error = "Not enough arguments"; | 1004 | |
| 1005 | if (!cc) | ||
| 1006 | return; | ||
| 1007 | |||
| 1008 | if (cc->io_queue) | ||
| 1009 | destroy_workqueue(cc->io_queue); | ||
| 1010 | if (cc->crypt_queue) | ||
| 1011 | destroy_workqueue(cc->crypt_queue); | ||
| 1012 | |||
| 1013 | if (cc->bs) | ||
| 1014 | bioset_free(cc->bs); | ||
| 1015 | |||
| 1016 | if (cc->page_pool) | ||
| 1017 | mempool_destroy(cc->page_pool); | ||
| 1018 | if (cc->req_pool) | ||
| 1019 | mempool_destroy(cc->req_pool); | ||
| 1020 | if (cc->io_pool) | ||
| 1021 | mempool_destroy(cc->io_pool); | ||
| 1022 | |||
| 1023 | if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) | ||
| 1024 | cc->iv_gen_ops->dtr(cc); | ||
| 1025 | |||
| 1026 | if (cc->tfm && !IS_ERR(cc->tfm)) | ||
| 1027 | crypto_free_ablkcipher(cc->tfm); | ||
| 1028 | |||
| 1029 | if (cc->dev) | ||
| 1030 | dm_put_device(ti, cc->dev); | ||
| 1031 | |||
| 1032 | kzfree(cc->cipher); | ||
| 1033 | kzfree(cc->cipher_mode); | ||
| 1034 | |||
| 1035 | /* Must zero key material before freeing */ | ||
| 1036 | kzfree(cc); | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | static int crypt_ctr_cipher(struct dm_target *ti, | ||
| 1040 | char *cipher_in, char *key) | ||
| 1041 | { | ||
| 1042 | struct crypt_config *cc = ti->private; | ||
| 1043 | char *tmp, *cipher, *chainmode, *ivmode, *ivopts; | ||
| 1044 | char *cipher_api = NULL; | ||
| 1045 | int ret = -EINVAL; | ||
| 1046 | |||
| 1047 | /* Convert to crypto api definition? */ | ||
| 1048 | if (strchr(cipher_in, '(')) { | ||
| 1049 | ti->error = "Bad cipher specification"; | ||
| 1020 | return -EINVAL; | 1050 | return -EINVAL; |
| 1021 | } | 1051 | } |
| 1022 | 1052 | ||
| 1023 | tmp = argv[0]; | 1053 | /* |
| 1054 | * Legacy dm-crypt cipher specification | ||
| 1055 | * cipher-mode-iv:ivopts | ||
| 1056 | */ | ||
| 1057 | tmp = cipher_in; | ||
| 1024 | cipher = strsep(&tmp, "-"); | 1058 | cipher = strsep(&tmp, "-"); |
| 1059 | |||
| 1060 | cc->cipher = kstrdup(cipher, GFP_KERNEL); | ||
| 1061 | if (!cc->cipher) | ||
| 1062 | goto bad_mem; | ||
| 1063 | |||
| 1064 | if (tmp) { | ||
| 1065 | cc->cipher_mode = kstrdup(tmp, GFP_KERNEL); | ||
| 1066 | if (!cc->cipher_mode) | ||
| 1067 | goto bad_mem; | ||
| 1068 | } | ||
| 1069 | |||
| 1025 | chainmode = strsep(&tmp, "-"); | 1070 | chainmode = strsep(&tmp, "-"); |
| 1026 | ivopts = strsep(&tmp, "-"); | 1071 | ivopts = strsep(&tmp, "-"); |
| 1027 | ivmode = strsep(&ivopts, ":"); | 1072 | ivmode = strsep(&ivopts, ":"); |
| 1028 | 1073 | ||
| 1029 | if (tmp) | 1074 | if (tmp) |
| 1030 | DMWARN("Unexpected additional cipher options"); | 1075 | DMWARN("Ignoring unexpected additional cipher options"); |
| 1031 | |||
| 1032 | key_size = strlen(argv[1]) >> 1; | ||
| 1033 | |||
| 1034 | cc = kzalloc(sizeof(*cc) + key_size * sizeof(u8), GFP_KERNEL); | ||
| 1035 | if (cc == NULL) { | ||
| 1036 | ti->error = | ||
| 1037 | "Cannot allocate transparent encryption context"; | ||
| 1038 | return -ENOMEM; | ||
| 1039 | } | ||
| 1040 | 1076 | ||
| 1041 | /* Compatibility mode for old dm-crypt cipher strings */ | 1077 | /* Compatibility mode for old dm-crypt mappings */ |
| 1042 | if (!chainmode || (strcmp(chainmode, "plain") == 0 && !ivmode)) { | 1078 | if (!chainmode || (!strcmp(chainmode, "plain") && !ivmode)) { |
| 1079 | kfree(cc->cipher_mode); | ||
| 1080 | cc->cipher_mode = kstrdup("cbc-plain", GFP_KERNEL); | ||
| 1043 | chainmode = "cbc"; | ||
