Skip to content

Commit 870af77

Browse files
bbkzzJaegeuk Kim
authored andcommitted
f2fs: do some cleanup for f2fs module init
Just for cleanup, no functional changes. Signed-off-by: Yangtao Li <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 398bb30 commit 870af77

File tree

5 files changed

+14
-62
lines changed

5 files changed

+14
-62
lines changed

fs/f2fs/compress.c

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ MODULE_PARM_DESC(num_compress_pages,
567567
int f2fs_init_compress_mempool(void)
568568
{
569569
compress_page_pool = mempool_create_page_pool(num_compress_pages, 0);
570-
if (!compress_page_pool)
571-
return -ENOMEM;
572-
573-
return 0;
570+
return compress_page_pool ? 0 : -ENOMEM;
574571
}
575572

576573
void f2fs_destroy_compress_mempool(void)
@@ -1983,63 +1980,32 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi)
19831980

19841981
sbi->page_array_slab = f2fs_kmem_cache_create(slab_name,
19851982
sbi->page_array_slab_size);
1986-
if (!sbi->page_array_slab)
1987-
return -ENOMEM;
1988-
return 0;
1983+
return sbi->page_array_slab ? 0 : -ENOMEM;
19891984
}
19901985

19911986
void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
19921987
{
19931988
kmem_cache_destroy(sbi->page_array_slab);
19941989
}
19951990

1996-
static int __init f2fs_init_cic_cache(void)
1991+
int __init f2fs_init_compress_cache(void)
19971992
{
19981993
cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry",
19991994
sizeof(struct compress_io_ctx));
20001995
if (!cic_entry_slab)
20011996
return -ENOMEM;
2002-
return 0;
2003-
}
2004-
2005-
static void f2fs_destroy_cic_cache(void)
2006-
{
2007-
kmem_cache_destroy(cic_entry_slab);
2008-
}
2009-
2010-
static int __init f2fs_init_dic_cache(void)
2011-
{
20121997
dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry",
20131998
sizeof(struct decompress_io_ctx));
20141999
if (!dic_entry_slab)
2015-
return -ENOMEM;
2016-
return 0;
2017-
}
2018-
2019-
static void f2fs_destroy_dic_cache(void)
2020-
{
2021-
kmem_cache_destroy(dic_entry_slab);
2022-
}
2023-
2024-
int __init f2fs_init_compress_cache(void)
2025-
{
2026-
int err;
2027-
2028-
err = f2fs_init_cic_cache();
2029-
if (err)
2030-
goto out;
2031-
err = f2fs_init_dic_cache();
2032-
if (err)
20332000
goto free_cic;
20342001
return 0;
20352002
free_cic:
2036-
f2fs_destroy_cic_cache();
2037-
out:
2003+
kmem_cache_destroy(cic_entry_slab);
20382004
return -ENOMEM;
20392005
}
20402006

20412007
void f2fs_destroy_compress_cache(void)
20422008
{
2043-
f2fs_destroy_dic_cache();
2044-
f2fs_destroy_cic_cache();
2009+
kmem_cache_destroy(dic_entry_slab);
2010+
kmem_cache_destroy(cic_entry_slab);
20452011
}

fs/f2fs/data.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ static struct bio_set f2fs_bioset;
3939

4040
int __init f2fs_init_bioset(void)
4141
{
42-
if (bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE,
43-
0, BIOSET_NEED_BVECS))
44-
return -ENOMEM;
45-
return 0;
42+
return bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE,
43+
0, BIOSET_NEED_BVECS);
4644
}
4745

4846
void f2fs_destroy_bioset(void)
@@ -4090,9 +4088,7 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi)
40904088
sbi->post_read_wq = alloc_workqueue("f2fs_post_read_wq",
40914089
WQ_UNBOUND | WQ_HIGHPRI,
40924090
num_online_cpus());
4093-
if (!sbi->post_read_wq)
4094-
return -ENOMEM;
4095-
return 0;
4091+
return sbi->post_read_wq ? 0 : -ENOMEM;
40964092
}
40974093

40984094
void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi)
@@ -4105,9 +4101,7 @@ int __init f2fs_init_bio_entry_cache(void)
41054101
{
41064102
bio_entry_slab = f2fs_kmem_cache_create("f2fs_bio_entry_slab",
41074103
sizeof(struct bio_entry));
4108-
if (!bio_entry_slab)
4109-
return -ENOMEM;
4110-
return 0;
4104+
return bio_entry_slab ? 0 : -ENOMEM;
41114105
}
41124106

41134107
void f2fs_destroy_bio_entry_cache(void)

fs/f2fs/gc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,9 +1904,7 @@ int __init f2fs_create_garbage_collection_cache(void)
19041904
{
19051905
victim_entry_slab = f2fs_kmem_cache_create("f2fs_victim_entry",
19061906
sizeof(struct victim_entry));
1907-
if (!victim_entry_slab)
1908-
return -ENOMEM;
1909-
return 0;
1907+
return victim_entry_slab ? 0 : -ENOMEM;
19101908
}
19111909

19121910
void f2fs_destroy_garbage_collection_cache(void)

fs/f2fs/recovery.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,7 @@ int __init f2fs_create_recovery_cache(void)
923923
{
924924
fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
925925
sizeof(struct fsync_inode_entry));
926-
if (!fsync_entry_slab)
927-
return -ENOMEM;
928-
return 0;
926+
return fsync_entry_slab ? 0 : -ENOMEM;
929927
}
930928

931929
void f2fs_destroy_recovery_cache(void)

fs/f2fs/super.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ static int __init f2fs_create_casefold_cache(void)
288288
{
289289
f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name",
290290
F2FS_NAME_LEN);
291-
if (!f2fs_cf_name_slab)
292-
return -ENOMEM;
293-
return 0;
291+
return f2fs_cf_name_slab ? 0 : -ENOMEM;
294292
}
295293

296294
static void f2fs_destroy_casefold_cache(void)
@@ -4647,9 +4645,7 @@ static int __init init_inodecache(void)
46474645
f2fs_inode_cachep = kmem_cache_create("f2fs_inode_cache",
46484646
sizeof(struct f2fs_inode_info), 0,
46494647
SLAB_RECLAIM_ACCOUNT|SLAB_ACCOUNT, NULL);
4650-
if (!f2fs_inode_cachep)
4651-
return -ENOMEM;
4652-
return 0;
4648+
return f2fs_inode_cachep ? 0 : -ENOMEM;
46534649
}
46544650

46554651
static void destroy_inodecache(void)

0 commit comments

Comments
 (0)