diff options
author | Eric Biggers <ebiggers@google.com> | 2017-02-22 16:25:14 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2017-03-15 14:15:47 -0400 |
commit | 94840e3c802daa1a62985957f36ac48faf8ceedd (patch) | |
tree | 09901080ff440233d2c092bd51a2aa296a2d9710 | |
parent | 1b53cf9815bb4744958d41f3795d5d5a1d365e2d (diff) |
fscrypt: eliminate ->prepare_context() operation
The only use of the ->prepare_context() fscrypt operation was to allow
ext4 to evict inline data from the inode before ->set_context().
However, there is no reason why this cannot be done as simply the first
step in ->set_context(), and in fact it makes more sense to do it that
way because then the policy modes and flags get validated before any
real work is done. Therefore, merge ext4_prepare_context() into
ext4_set_context(), and remove ->prepare_context().
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/crypto/policy.c | 7 | ||||
-rw-r--r-- | fs/ext4/super.c | 10 | ||||
-rw-r--r-- | include/linux/fscrypt_common.h | 1 |
3 files changed, 4 insertions, 14 deletions
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 14b76da71269..4908906d54d5 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c | |||
@@ -33,17 +33,10 @@ static int create_encryption_context_from_policy(struct inode *inode, | |||
33 | const struct fscrypt_policy *policy) | 33 | const struct fscrypt_policy *policy) |
34 | { | 34 | { |
35 | struct fscrypt_context ctx; | 35 | struct fscrypt_context ctx; |
36 | int res; | ||
37 | 36 | ||
38 | if (!inode->i_sb->s_cop->set_context) | 37 | if (!inode->i_sb->s_cop->set_context) |
39 | return -EOPNOTSUPP; | 38 | return -EOPNOTSUPP; |
40 | 39 | ||
41 | if (inode->i_sb->s_cop->prepare_context) { | ||
42 | res = inode->i_sb->s_cop->prepare_context(inode); | ||
43 | if (res) | ||
44 | return res; | ||
45 | } | ||
46 | |||
47 | ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1; | 40 | ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1; |
48 | memcpy(ctx.master_key_descriptor, policy->master_key_descriptor, | 41 | memcpy(ctx.master_key_descriptor, policy->master_key_descriptor, |
49 | FS_KEY_DESCRIPTOR_SIZE); | 42 | FS_KEY_DESCRIPTOR_SIZE); |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2e03a0a88d92..a9448db1cf7e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1120,17 +1120,16 @@ static int ext4_get_context(struct inode *inode, void *ctx, size_t len) | |||
1120 | EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len); | 1120 | EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | static int ext4_prepare_context(struct inode *inode) | ||
1124 | { | ||
1125 | return ext4_convert_inline_data(inode); | ||
1126 | } | ||
1127 | |||
1128 | static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, | 1123 | static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, |
1129 | void *fs_data) | 1124 | void *fs_data) |
1130 | { | 1125 | { |
1131 | handle_t *handle = fs_data; | 1126 | handle_t *handle = fs_data; |
1132 | int res, res2, retries = 0; | 1127 | int res, res2, retries = 0; |
1133 | 1128 | ||
1129 | res = ext4_convert_inline_data(inode); | ||
1130 | if (res) | ||
1131 | return res; | ||
1132 | |||
1134 | /* | 1133 | /* |
1135 | * If a journal handle was specified, then the encryption context is | 1134 | * If a journal handle was specified, then the encryption context is |
1136 | * being set on a new inode via inheritance and is part of a larger | 1135 | * being set on a new inode via inheritance and is part of a larger |
@@ -1196,7 +1195,6 @@ static unsigned ext4_max_namelen(struct inode *inode) | |||
1196 | static const struct fscrypt_operations ext4_cryptops = { | 1195 | static const struct fscrypt_operations ext4_cryptops = { |
1197 | .key_prefix = "ext4:", | 1196 | .key_prefix = "ext4:", |
1198 | .get_context = ext4_get_context, | 1197 | .get_context = ext4_get_context, |
1199 | .prepare_context = ext4_prepare_context, | ||
1200 | .set_context = ext4_set_context, | 1198 | .set_context = ext4_set_context, |
1201 | .dummy_context = ext4_dummy_context, | 1199 | .dummy_context = ext4_dummy_context, |
1202 | .is_encrypted = ext4_encrypted_inode, | 1200 | .is_encrypted = ext4_encrypted_inode, |
diff --git a/include/linux/fscrypt_common.h b/include/linux/fscrypt_common.h index 547f81592ba1..10c1abfbac6c 100644 --- a/include/linux/fscrypt_common.h +++ b/include/linux/fscrypt_common.h | |||
@@ -87,7 +87,6 @@ struct fscrypt_operations { | |||
87 | unsigned int flags; | 87 | unsigned int flags; |
88 | const char *key_prefix; | 88 | const char *key_prefix; |
89 | int (*get_context)(struct inode *, void *, size_t); | 89 | int (*get_context)(struct inode *, void *, size_t); |
90 | int (*prepare_context)(struct inode *); | ||
91 | int (*set_context)(struct inode *, const void *, size_t, void *); | 90 | int (*set_context)(struct inode *, const void *, size_t, void *); |
92 | int (*dummy_context)(struct inode *); | 91 | int (*dummy_context)(struct inode *); |
93 | bool (*is_encrypted)(struct inode *); | 92 | bool (*is_encrypted)(struct inode *); |