inode_init_once(&vi->vfs_inode);
}
-static int __init erofs_init_inode_cache(void)
-{
- erofs_inode_cachep = kmem_cache_create("erofs_inode",
- sizeof(struct erofs_vnode), 0,
- SLAB_RECLAIM_ACCOUNT,
- init_once);
-
- return erofs_inode_cachep ? 0 : -ENOMEM;
-}
-
-static void erofs_exit_inode_cache(void)
-{
- kmem_cache_destroy(erofs_inode_cachep);
-}
-
static struct inode *alloc_inode(struct super_block *sb)
{
struct erofs_vnode *vi =
erofs_check_ondisk_layout_definitions();
infoln("initializing erofs " EROFS_VERSION);
- err = erofs_init_inode_cache();
- if (err)
+ erofs_inode_cachep = kmem_cache_create("erofs_inode",
+ sizeof(struct erofs_vnode), 0,
+ SLAB_RECLAIM_ACCOUNT,
+ init_once);
+ if (!erofs_inode_cachep) {
+ err = -ENOMEM;
goto icache_err;
+ }
err = erofs_init_shrinker();
if (err)
zip_err:
erofs_exit_shrinker();
shrinker_err:
- erofs_exit_inode_cache();
+ kmem_cache_destroy(erofs_inode_cachep);
icache_err:
return err;
}
unregister_filesystem(&erofs_fs_type);
z_erofs_exit_zip_subsystem();
erofs_exit_shrinker();
- erofs_exit_inode_cache();
+
+ /* Ensure all RCU free inodes are safe before cache is destroyed. */
+ rcu_barrier();
+ kmem_cache_destroy(erofs_inode_cachep);
infoln("successfully finalize erofs");
}