diff --git a/fs/sdcardfs/file.c b/fs/sdcardfs/file.c index 271c4c4cb760..70134f3f296c 100644 --- a/fs/sdcardfs/file.c +++ b/fs/sdcardfs/file.c @@ -23,6 +23,8 @@ #include #endif +struct kmem_cache *kmem_file_info_pool; + static ssize_t sdcardfs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { @@ -256,7 +258,7 @@ static int sdcardfs_open(struct inode *inode, struct file *file) } file->private_data = - kzalloc(sizeof(struct sdcardfs_file_info), GFP_KERNEL); + kmem_cache_zalloc(kmem_file_info_pool, GFP_KERNEL); if (!SDCARDFS_F(file)) { err = -ENOMEM; goto out_revert_cred; @@ -278,7 +280,7 @@ static int sdcardfs_open(struct inode *inode, struct file *file) } if (err) - kfree(SDCARDFS_F(file)); + kmem_cache_free(kmem_file_info_pool, SDCARDFS_F(file)); else sdcardfs_copy_and_fix_attrs(inode, sdcardfs_lower_inode(inode)); @@ -314,7 +316,7 @@ static int sdcardfs_file_release(struct inode *inode, struct file *file) fput(lower_file); } - kfree(SDCARDFS_F(file)); + kmem_cache_free(kmem_file_info_pool, SDCARDFS_F(file)); return 0; } diff --git a/fs/sdcardfs/main.c b/fs/sdcardfs/main.c index 905b1a9dfe3c..7b847039a63b 100644 --- a/fs/sdcardfs/main.c +++ b/fs/sdcardfs/main.c @@ -475,6 +475,12 @@ static int __init init_sdcardfs_fs(void) pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n"); + kmem_file_info_pool = KMEM_CACHE(sdcardfs_file_info, SLAB_HWCACHE_ALIGN); + if (!kmem_file_info_pool) { + err = -ENOMEM; + goto err; + } + err = sdcardfs_init_inode_cache(); if (err) goto out; @@ -491,6 +497,7 @@ out: sdcardfs_destroy_dentry_cache(); packagelist_exit(); } +err: return err; } @@ -500,6 +507,7 @@ static void __exit exit_sdcardfs_fs(void) sdcardfs_destroy_dentry_cache(); packagelist_exit(); unregister_filesystem(&sdcardfs_fs_type); + kmem_cache_destroy(kmem_file_info_pool); pr_info("Completed sdcardfs module unload\n"); } diff --git a/fs/sdcardfs/sdcardfs.h b/fs/sdcardfs/sdcardfs.h index c9d855da629f..8c353a2ba10d 100644 --- a/fs/sdcardfs/sdcardfs.h +++ b/fs/sdcardfs/sdcardfs.h @@ -654,4 +654,6 @@ static inline bool qstr_case_eq(const struct qstr *q1, const struct qstr *q2) #define QSTR_LITERAL(string) QSTR_INIT(string, sizeof(string)-1) +extern struct kmem_cache *kmem_file_info_pool; + #endif /* not _SDCARDFS_H_ */