All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH 4/6] f2fs crypto: get rid of ci_mode from struct f2fs_crypt_info
Date: Tue, 12 May 2015 17:40:32 -0700	[thread overview]
Message-ID: <1431477634-48111-4-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1431477634-48111-1-git-send-email-jaegeuk@kernel.org>

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       | 11 +++++------
 fs/f2fs/crypto_fname.c |  4 ++--
 fs/f2fs/crypto_key.c   | 12 ++++++------
 fs/f2fs/f2fs_crypto.h  |  1 -
 4 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c
index 5491d1e..c1a5c6f 100644
--- a/fs/f2fs/crypto.c
+++ b/fs/f2fs/crypto.c
@@ -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
diff --git a/fs/f2fs/crypto_fname.c b/fs/f2fs/crypto_fname.c
index 8f3ff9b..e3a1bdc 100644
--- a/fs/f2fs/crypto_fname.c
+++ b/fs/f2fs/crypto_fname.c
@@ -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;
 	}
 
diff --git a/fs/f2fs/crypto_key.c b/fs/f2fs/crypto_key.c
index 2bdcae5..dbfc616 100644
--- a/fs/f2fs/crypto_key.c
+++ b/fs/f2fs/crypto_key.c
@@ -142,14 +142,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,
diff --git a/fs/f2fs/f2fs_crypto.h b/fs/f2fs/f2fs_crypto.h
index 6e41394..58682d2 100644
--- a/fs/f2fs/f2fs_crypto.h
+++ b/fs/f2fs/f2fs_crypto.h
@@ -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;
-- 
2.1.1


WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 4/6] f2fs crypto: get rid of ci_mode from struct f2fs_crypt_info
Date: Tue, 12 May 2015 17:40:32 -0700	[thread overview]
Message-ID: <1431477634-48111-4-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1431477634-48111-1-git-send-email-jaegeuk@kernel.org>

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       | 11 +++++------
 fs/f2fs/crypto_fname.c |  4 ++--
 fs/f2fs/crypto_key.c   | 12 ++++++------
 fs/f2fs/f2fs_crypto.h  |  1 -
 4 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c
index 5491d1e..c1a5c6f 100644
--- a/fs/f2fs/crypto.c
+++ b/fs/f2fs/crypto.c
@@ -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
diff --git a/fs/f2fs/crypto_fname.c b/fs/f2fs/crypto_fname.c
index 8f3ff9b..e3a1bdc 100644
--- a/fs/f2fs/crypto_fname.c
+++ b/fs/f2fs/crypto_fname.c
@@ -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;
 	}
 
diff --git a/fs/f2fs/crypto_key.c b/fs/f2fs/crypto_key.c
index 2bdcae5..dbfc616 100644
--- a/fs/f2fs/crypto_key.c
+++ b/fs/f2fs/crypto_key.c
@@ -142,14 +142,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,
diff --git a/fs/f2fs/f2fs_crypto.h b/fs/f2fs/f2fs_crypto.h
index 6e41394..58682d2 100644
--- a/fs/f2fs/f2fs_crypto.h
+++ b/fs/f2fs/f2fs_crypto.h
@@ -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;
-- 
2.1.1


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y

  parent reply	other threads:[~2015-05-13  0:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13  0:40 [PATCH 1/6] f2fs crypto: free encryption_info at f2fs_evict_inode Jaegeuk Kim
2015-05-13  0:40 ` [PATCH 2/6] f2fs crypto: not support fcollapse for encrypted inode Jaegeuk Kim
2015-05-13  0:40   ` Jaegeuk Kim
2015-05-13  0:40 ` [PATCH 3/6] f2fs crypto: use slab caches Jaegeuk Kim
2015-05-13  0:40 ` Jaegeuk Kim [this message]
2015-05-13  0:40   ` [PATCH 4/6] f2fs crypto: get rid of ci_mode from struct f2fs_crypt_info Jaegeuk Kim
2015-05-13  0:40 ` [PATCH 5/6] f2fs crypto: shrink size of the f2fs_crypto_ctx structure Jaegeuk Kim
2015-05-13  0:40   ` Jaegeuk Kim
2015-05-13  0:40 ` [PATCH 6/6] f2fs crypto: require CONFIG_CRYPTO_CTR if f2fs encryption is enabled Jaegeuk Kim
2015-05-13  0:40   ` Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431477634-48111-4-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.