f2fs crypto: use slab caches

This patch integrates the below patch into f2fs.

"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>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/fs/f2fs/crypto_key.c b/fs/f2fs/crypto_key.c
index c7d414d..6b9312b 100644
--- a/fs/f2fs/crypto_key.c
+++ b/fs/f2fs/crypto_key.c
@@ -99,7 +99,7 @@
 		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(f2fs_crypt_info_cachep, ci);
 	fi->i_crypt_info = NULL;
 }
 
@@ -137,7 +137,7 @@
 		return -EINVAL;
 	res = 0;
 
-	crypt_info = kmalloc(sizeof(struct f2fs_crypt_info), GFP_NOFS);
+	crypt_info = kmem_cache_alloc(f2fs_crypt_info_cachep, GFP_NOFS);
 	if (!crypt_info)
 		return -ENOMEM;
 
@@ -187,7 +187,7 @@
 	if (res < 0) {
 		if (res == -ENOKEY)
 			res = 0;
-		kfree(crypt_info);
+		kmem_cache_free(f2fs_crypt_info_cachep, crypt_info);
 	} else {
 		fi->i_crypt_info = crypt_info;
 		crypt_info->ci_keyring_key = keyring_key;