FS: consolidate inode cache initialization
Subsystems (2)
RFC 1/1 FS: consolidate inode cache initialization
Currently, all filesystems directly call kmem_cache_create() through static init_inodecache() and generally use the same slab flags with <fsname>_inode_cache.
This patch declares _init_inode_cache() in libfs which uses file_system_fs name to forge cache name and applies the update on AFFS as an example.
If the idea is interesting, should I send 1 patch for _init_inode_cache() addition and 1 patch for each FS update ?
Regards,
Fabian
Signed-off-by Fabian Frederick <[email protected]>
--- fs/affs/super.c | 17 ++++------------- fs/libfs.c | 15 +++++++++++++++ include/linux/fs.h | 3 +++ 3 files changed, 22 insertions(+), 13 deletions(-)
fs/affs/super.c +4 -13
@@ -126,18 +126,6 @@ static void init_once(void *foo)inode_init_once (&ei->vfs_inode); } -static int __init init_inodecache (void ) -{ - affs_inode_cachep =kmem_cache_create ("affs_inode_cache" , -sizeof (struct affs_inode_info ), -0 , (SLAB_RECLAIM_ACCOUNT | -SLAB_MEM_SPREAD ), - init_once); -if (affs_inode_cachep ==NULL ) -return -ENOMEM ; -return 0 ; -} -static void destroy_inodecache (void ) {/*
@@ -623,7 +611,10 @@ MODULE_ALIAS_FS("affs");static int __init init_affs_fs (void ) { -int err =init_inodecache (); +int err; + + err =_init_inodecache (&affs_inode_cachep, &affs_fs_type, +sizeof (struct affs_inode_info ), init_once);if (err) goto out1; err =register_filesystem (&affs_fs_type);
fs/libfs.c +15 -0
@@ -1203,3 +1203,18 @@ bool is_empty_dir_inode(struct inode *inode)return (inode->i_fop == &empty_dir_operations) && (inode->i_op == &empty_dir_inode_operations); } + +int _init_inodecache (struct kmem_cache **cachep,struct file_system_type *fs, +size_t fs_inodeinfo_len,void *init_once) +{ +char buf[32 ]; + +sprintf (buf,"%s_inode_cache" , fs->name); + *cachep =kmem_cache_create (buf, fs_inodeinfo_len,0 , + (SLAB_RECLAIM_ACCOUNT |SLAB_MEM_SPREAD ), + init_once); +if (!*cachep) +return -ENOMEM ; +return 0 ; +} +EXPORT_SYMBOL (_init_inodecache);
include/linux/fs.h +3 -0
@@ -2834,6 +2834,9 @@ extern int generic_file_fsync(struct file *, loff_t, loff_t, int);extern int generic_check_addressable (unsigned ,u64 ); +extern int _init_inodecache (struct kmem_cache **,struct file_system_type *, +size_t ,void *); +#ifdef CONFIG_MIGRATION extern int buffer_migrate_page(struct address_space *, struct page *, struct page *,
Signature · 4 lines
2.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in