ext4 crypto: get rid of ci_mode from struct ext4_crypt_info
authorTheodore Ts'o <tytso@mit.edu>
Mon, 18 May 2015 17:20:47 +0000 (13:20 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 18 May 2015 17:20:47 +0000 (13:20 -0400)
The ci_mode field was superfluous, and getting rid of it gets rid of
an unused hole in the structure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/crypto.c
fs/ext4/crypto_fname.c
fs/ext4/crypto_key.c
fs/ext4/ext4_crypto.h

index 1c34f0eb125b5b94704f5a4d6d50629fca6322ee..9969d054cd88c066c5b373c3e21bd0491e81aa34 100644 (file)
@@ -137,14 +137,13 @@ struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode)
 
        /* Allocate a new Crypto API context if we don't already have
         * one or if it isn't the right mode. */
-       BUG_ON(ci->ci_mode == EXT4_ENCRYPTION_MODE_INVALID);
-       if (ctx->tfm && (ctx->mode != ci->ci_mode)) {
+       if (ctx->tfm && (ctx->mode != ci->ci_data_mode)) {
                crypto_free_tfm(ctx->tfm);
                ctx->tfm = NULL;
                ctx->mode = EXT4_ENCRYPTION_MODE_INVALID;
        }
        if (!ctx->tfm) {
-               switch (ci->ci_mode) {
+               switch (ci->ci_data_mode) {
                case EXT4_ENCRYPTION_MODE_AES_256_XTS:
                        ctx->tfm = crypto_ablkcipher_tfm(
                                crypto_alloc_ablkcipher("xts(aes)", 0, 0));
@@ -162,9 +161,9 @@ struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode)
                        ctx->tfm = NULL;
                        goto out;
                }
-               ctx->mode = ci->ci_mode;
+               ctx->mode = ci->ci_data_mode;
        }
-       BUG_ON(ci->ci_size != ext4_encryption_key_size(ci->ci_mode));
+       BUG_ON(ci->ci_size != ext4_encryption_key_size(ci->ci_data_mode));
 
        /* There shouldn't be a bounce page attached to the crypto
         * context at this point. */
@@ -321,7 +320,7 @@ static int ext4_page_crypto(struct ext4_crypto_ctx *ctx,
        int res = 0;
 
        BUG_ON(!ctx->tfm);
-       BUG_ON(ctx->mode != ei->i_crypt_info->ci_mode);
+       BUG_ON(ctx->mode != ei->i_crypt_info->ci_data_mode);
 
        if (ctx->mode != EXT4_ENCRYPTION_MODE_AES_256_XTS) {
                printk_ratelimited(KERN_ERR
index 374d0e790315e8c6223b8fab2f04c8e7308bfbbb..e63dd294d7aad53f5c28be04e6a4105a3ec86dd8 100644 (file)
@@ -272,9 +272,9 @@ int ext4_setup_fname_crypto(struct inode *inode)
        if (!ci || ci->ci_ctfm)
                return 0;
 
-       if (ci->ci_mode != EXT4_ENCRYPTION_MODE_AES_256_CTS) {
+       if (ci->ci_filename_mode != EXT4_ENCRYPTION_MODE_AES_256_CTS) {
                printk_once(KERN_WARNING "ext4: unsupported key mode %d\n",
-                           ci->ci_mode);
+                           ci->ci_filename_mode);
                return -ENOKEY;
        }
 
index d6abe4687cd5b2ce9c079b3f0f5109db278225e0..858d7d67a4e19c47ed877e633873f093f86db07a 100644 (file)
@@ -152,14 +152,13 @@ int _ext4_get_encryption_info(struct inode *inode)
        memcpy(crypt_info->ci_master_key, ctx.master_key_descriptor,
               sizeof(crypt_info->ci_master_key));
        if (S_ISREG(inode->i_mode))
-               crypt_info->ci_mode = ctx.contents_encryption_mode;
+               crypt_info->ci_size =
+                       ext4_encryption_key_size(crypt_info->ci_data_mode);
        else if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
-               crypt_info->ci_mode = ctx.filenames_encryption_mode;
-       else {
-               printk(KERN_ERR "ext4 crypto: Unsupported inode type.\n");
+               crypt_info->ci_size =
+                       ext4_encryption_key_size(crypt_info->ci_filename_mode);
+       else
                BUG();
-       }
-       crypt_info->ci_size = ext4_encryption_key_size(crypt_info->ci_mode);
        BUG_ON(!crypt_info->ci_size);
        if (DUMMY_ENCRYPTION_ENABLED(sbi)) {
                memset(crypt_info->ci_raw, 0x42, EXT4_AES_256_XTS_KEY_SIZE);
index d29687c232bd4a60c0fca00c73f91d7b0b80d025..69faf0e9f87460adc703e846f231b6468254f1e2 100644 (file)
@@ -74,7 +74,6 @@ struct ext4_encryption_key {
 } __attribute__((__packed__));
 
 struct ext4_crypt_info {
-       unsigned char   ci_mode;
        unsigned char   ci_size;
        char            ci_data_mode;
        char            ci_filename_mode;