diff options
author | Theodore Ts'o <tytso@mit.edu> | 2015-05-18 13:19:47 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-05-18 13:19:47 -0400 |
commit | 8ee0371470038371729a39ee6669a2132ac47649 (patch) | |
tree | ffb2781725fa6cdbd98a19d03165c7772189ba81 /fs/ext4/crypto_key.c | |
parent | f5aed2c2a825618553b20e8a67109570489b40d7 (diff) | |
download | linux-8ee0371470038371729a39ee6669a2132ac47649.tar.bz2 |
ext4 crypto: use slab caches
Use slab caches the ext4_crypto_ctx and ext4_crypt_info structures for
slighly better memory efficiency and debuggability.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/crypto_key.c')
-rw-r--r-- | fs/ext4/crypto_key.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ext4/crypto_key.c b/fs/ext4/crypto_key.c index 0075e43ffea6..d6abe4687cd5 100644 --- a/fs/ext4/crypto_key.c +++ b/fs/ext4/crypto_key.c @@ -96,7 +96,7 @@ void ext4_free_encryption_info(struct inode *inode) key_put(ci->ci_keyring_key); crypto_free_ablkcipher(ci->ci_ctfm); memzero_explicit(&ci->ci_raw, sizeof(ci->ci_raw)); - kfree(ci); + kmem_cache_free(ext4_crypt_info_cachep, ci); ei->i_crypt_info = NULL; } @@ -113,6 +113,12 @@ int _ext4_get_encryption_info(struct inode *inode) struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); int res; + if (!ext4_read_workqueue) { + res = ext4_init_crypto(); + if (res) + return res; + } + if (ei->i_crypt_info) { if (!ei->i_crypt_info->ci_keyring_key || key_validate(ei->i_crypt_info->ci_keyring_key) == 0) @@ -134,7 +140,7 @@ int _ext4_get_encryption_info(struct inode *inode) return -EINVAL; res = 0; - crypt_info = kmalloc(sizeof(struct ext4_crypt_info), GFP_KERNEL); + crypt_info = kmem_cache_alloc(ext4_crypt_info_cachep, GFP_KERNEL); if (!crypt_info) return -ENOMEM; @@ -188,7 +194,7 @@ out: if (res < 0) { if (res == -ENOKEY) res = 0; - kfree(crypt_info); + kmem_cache_free(ext4_crypt_info_cachep, crypt_info); } else { ei->i_crypt_info = crypt_info; crypt_info->ci_keyring_key = keyring_key; |