]> git.karo-electronics.de Git - linux-beck.git/commitdiff
f2fs crypto: get rid of ci_mode from struct f2fs_crypt_info
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 12 May 2015 20:33:00 +0000 (13:33 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 1 Jun 2015 23:20:56 +0000 (16:20 -0700)
This patch integrates the below patch into f2fs.

"ext4 crypto: get rid of ci_mode from struct ext4_crypt_info

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>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/crypto.c
fs/f2fs/crypto_fname.c
fs/f2fs/crypto_key.c
fs/f2fs/f2fs_crypto.h

index 4057c07242c69fa89a701b575ab30ad62aaae184..e4058b92c774e7060efcdbf9084cc4a0180dba0d 100644 (file)
@@ -151,14 +151,13 @@ struct f2fs_crypto_ctx *f2fs_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 == F2FS_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 = F2FS_ENCRYPTION_MODE_INVALID;
        }
        if (!ctx->tfm) {
-               switch (ci->ci_mode) {
+               switch (ci->ci_data_mode) {
                case F2FS_ENCRYPTION_MODE_AES_256_XTS:
                        ctx->tfm = crypto_ablkcipher_tfm(
                                crypto_alloc_ablkcipher("xts(aes)", 0, 0));
@@ -178,9 +177,9 @@ struct f2fs_crypto_ctx *f2fs_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 != f2fs_encryption_key_size(ci->ci_mode));
+       BUG_ON(ci->ci_size != f2fs_encryption_key_size(ci->ci_data_mode));
 
        /*
         * There shouldn't be a bounce page attached to the crypto
@@ -388,7 +387,7 @@ static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx,
        int res = 0;
 
        BUG_ON(!ctx->tfm);
-       BUG_ON(ctx->mode != fi->i_crypt_info->ci_mode);
+       BUG_ON(ctx->mode != fi->i_crypt_info->ci_data_mode);
 
        if (ctx->mode != F2FS_ENCRYPTION_MODE_AES_256_XTS) {
                printk_ratelimited(KERN_ERR
index 8f3ff9b3caebffdfa3030c47f17ae252284d84f7..e3a1bdc70b03b8bb48c0dab39f385590b7a44ee4 100644 (file)
@@ -269,9 +269,9 @@ int f2fs_setup_fname_crypto(struct inode *inode)
        if (!ci || ci->ci_ctfm)
                return 0;
 
-       if (ci->ci_mode != F2FS_ENCRYPTION_MODE_AES_256_CTS) {
+       if (ci->ci_filename_mode != F2FS_ENCRYPTION_MODE_AES_256_CTS) {
                printk_once(KERN_WARNING "f2fs: unsupported key mode %d\n",
-                               ci->ci_mode);
+                               ci->ci_filename_mode);
                return -ENOKEY;
        }
 
index 6b9312b281b72e773e702913aca4e83b96c0ad8b..5ae9cc8fd52b441e3203c273d0f77e9968b4db8b 100644 (file)
@@ -148,14 +148,14 @@ int _f2fs_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 =
+                       f2fs_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 "f2fs crypto: Unsupported inode type.\n");
+               crypt_info->ci_size =
+                       f2fs_encryption_key_size(crypt_info->ci_filename_mode);
+       else
                BUG();
-       }
-       crypt_info->ci_size = f2fs_encryption_key_size(crypt_info->ci_mode);
+
        BUG_ON(!crypt_info->ci_size);
 
        memcpy(full_key_descriptor, F2FS_KEY_DESC_PREFIX,
index 6e4139493ba5259cf422b09b1a80273500cfc3e0..58682d2830e990c2e3fe291abe86764ad9c4dce1 100644 (file)
@@ -75,7 +75,6 @@ struct f2fs_encryption_key {
 } __attribute__((__packed__));
 
 struct f2fs_crypt_info {
-       unsigned char   ci_mode;
        unsigned char   ci_size;
        char            ci_data_mode;
        char            ci_filename_mode;