f2fs: do some cleanup for f2fs module init
Just for cleanup, no functional changes. Signed-off-by: Yangtao Li <frank.li@vivo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
398bb30d4f
commit
870af777da
|
@ -567,10 +567,7 @@ MODULE_PARM_DESC(num_compress_pages,
|
||||||
int f2fs_init_compress_mempool(void)
|
int f2fs_init_compress_mempool(void)
|
||||||
{
|
{
|
||||||
compress_page_pool = mempool_create_page_pool(num_compress_pages, 0);
|
compress_page_pool = mempool_create_page_pool(num_compress_pages, 0);
|
||||||
if (!compress_page_pool)
|
return compress_page_pool ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_compress_mempool(void)
|
void f2fs_destroy_compress_mempool(void)
|
||||||
|
@ -1983,9 +1980,7 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi)
|
||||||
|
|
||||||
sbi->page_array_slab = f2fs_kmem_cache_create(slab_name,
|
sbi->page_array_slab = f2fs_kmem_cache_create(slab_name,
|
||||||
sbi->page_array_slab_size);
|
sbi->page_array_slab_size);
|
||||||
if (!sbi->page_array_slab)
|
return sbi->page_array_slab ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
|
void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
|
||||||
|
@ -1993,53 +1988,24 @@ void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
|
||||||
kmem_cache_destroy(sbi->page_array_slab);
|
kmem_cache_destroy(sbi->page_array_slab);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init f2fs_init_cic_cache(void)
|
int __init f2fs_init_compress_cache(void)
|
||||||
{
|
{
|
||||||
cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry",
|
cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry",
|
||||||
sizeof(struct compress_io_ctx));
|
sizeof(struct compress_io_ctx));
|
||||||
if (!cic_entry_slab)
|
if (!cic_entry_slab)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void f2fs_destroy_cic_cache(void)
|
|
||||||
{
|
|
||||||
kmem_cache_destroy(cic_entry_slab);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int __init f2fs_init_dic_cache(void)
|
|
||||||
{
|
|
||||||
dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry",
|
dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry",
|
||||||
sizeof(struct decompress_io_ctx));
|
sizeof(struct decompress_io_ctx));
|
||||||
if (!dic_entry_slab)
|
if (!dic_entry_slab)
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void f2fs_destroy_dic_cache(void)
|
|
||||||
{
|
|
||||||
kmem_cache_destroy(dic_entry_slab);
|
|
||||||
}
|
|
||||||
|
|
||||||
int __init f2fs_init_compress_cache(void)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = f2fs_init_cic_cache();
|
|
||||||
if (err)
|
|
||||||
goto out;
|
|
||||||
err = f2fs_init_dic_cache();
|
|
||||||
if (err)
|
|
||||||
goto free_cic;
|
goto free_cic;
|
||||||
return 0;
|
return 0;
|
||||||
free_cic:
|
free_cic:
|
||||||
f2fs_destroy_cic_cache();
|
kmem_cache_destroy(cic_entry_slab);
|
||||||
out:
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_compress_cache(void)
|
void f2fs_destroy_compress_cache(void)
|
||||||
{
|
{
|
||||||
f2fs_destroy_dic_cache();
|
kmem_cache_destroy(dic_entry_slab);
|
||||||
f2fs_destroy_cic_cache();
|
kmem_cache_destroy(cic_entry_slab);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,8 @@ static struct bio_set f2fs_bioset;
|
||||||
|
|
||||||
int __init f2fs_init_bioset(void)
|
int __init f2fs_init_bioset(void)
|
||||||
{
|
{
|
||||||
if (bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE,
|
return bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE,
|
||||||
0, BIOSET_NEED_BVECS))
|
0, BIOSET_NEED_BVECS);
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_bioset(void)
|
void f2fs_destroy_bioset(void)
|
||||||
|
@ -4090,9 +4088,7 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi)
|
||||||
sbi->post_read_wq = alloc_workqueue("f2fs_post_read_wq",
|
sbi->post_read_wq = alloc_workqueue("f2fs_post_read_wq",
|
||||||
WQ_UNBOUND | WQ_HIGHPRI,
|
WQ_UNBOUND | WQ_HIGHPRI,
|
||||||
num_online_cpus());
|
num_online_cpus());
|
||||||
if (!sbi->post_read_wq)
|
return sbi->post_read_wq ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi)
|
void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi)
|
||||||
|
@ -4105,9 +4101,7 @@ int __init f2fs_init_bio_entry_cache(void)
|
||||||
{
|
{
|
||||||
bio_entry_slab = f2fs_kmem_cache_create("f2fs_bio_entry_slab",
|
bio_entry_slab = f2fs_kmem_cache_create("f2fs_bio_entry_slab",
|
||||||
sizeof(struct bio_entry));
|
sizeof(struct bio_entry));
|
||||||
if (!bio_entry_slab)
|
return bio_entry_slab ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_bio_entry_cache(void)
|
void f2fs_destroy_bio_entry_cache(void)
|
||||||
|
|
|
@ -1904,9 +1904,7 @@ int __init f2fs_create_garbage_collection_cache(void)
|
||||||
{
|
{
|
||||||
victim_entry_slab = f2fs_kmem_cache_create("f2fs_victim_entry",
|
victim_entry_slab = f2fs_kmem_cache_create("f2fs_victim_entry",
|
||||||
sizeof(struct victim_entry));
|
sizeof(struct victim_entry));
|
||||||
if (!victim_entry_slab)
|
return victim_entry_slab ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_garbage_collection_cache(void)
|
void f2fs_destroy_garbage_collection_cache(void)
|
||||||
|
|
|
@ -923,9 +923,7 @@ int __init f2fs_create_recovery_cache(void)
|
||||||
{
|
{
|
||||||
fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
|
fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
|
||||||
sizeof(struct fsync_inode_entry));
|
sizeof(struct fsync_inode_entry));
|
||||||
if (!fsync_entry_slab)
|
return fsync_entry_slab ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_destroy_recovery_cache(void)
|
void f2fs_destroy_recovery_cache(void)
|
||||||
|
|
|
@ -288,9 +288,7 @@ static int __init f2fs_create_casefold_cache(void)
|
||||||
{
|
{
|
||||||
f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name",
|
f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name",
|
||||||
F2FS_NAME_LEN);
|
F2FS_NAME_LEN);
|
||||||
if (!f2fs_cf_name_slab)
|
return f2fs_cf_name_slab ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void f2fs_destroy_casefold_cache(void)
|
static void f2fs_destroy_casefold_cache(void)
|
||||||
|
@ -4647,9 +4645,7 @@ static int __init init_inodecache(void)
|
||||||
f2fs_inode_cachep = kmem_cache_create("f2fs_inode_cache",
|
f2fs_inode_cachep = kmem_cache_create("f2fs_inode_cache",
|
||||||
sizeof(struct f2fs_inode_info), 0,
|
sizeof(struct f2fs_inode_info), 0,
|
||||||
SLAB_RECLAIM_ACCOUNT|SLAB_ACCOUNT, NULL);
|
SLAB_RECLAIM_ACCOUNT|SLAB_ACCOUNT, NULL);
|
||||||
if (!f2fs_inode_cachep)
|
return f2fs_inode_cachep ? 0 : -ENOMEM;
|
||||||
return -ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_inodecache(void)
|
static void destroy_inodecache(void)
|
||||||
|
|
Loading…
Reference in New Issue