Skip to content

Commit 7096fae

Browse files
KunWuChanrichardweinberger
authored andcommitted
jffs2: Simplify the allocation of slab caches
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. And change cache name from 'jffs2_tmp_dnode' to 'jffs2_tmp_dnode_info'. Signed-off-by: Kunwu Chan <chentao@kylinos.cn> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 2e0a808 commit 7096fae

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

fs/jffs2/malloc.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,19 @@ static struct kmem_cache *xattr_ref_cache;
3333

3434
int __init jffs2_create_slab_caches(void)
3535
{
36-
full_dnode_slab = kmem_cache_create("jffs2_full_dnode",
37-
sizeof(struct jffs2_full_dnode),
38-
0, 0, NULL);
36+
full_dnode_slab = KMEM_CACHE(jffs2_full_dnode, 0);
3937
if (!full_dnode_slab)
4038
goto err;
4139

42-
raw_dirent_slab = kmem_cache_create("jffs2_raw_dirent",
43-
sizeof(struct jffs2_raw_dirent),
44-
0, SLAB_HWCACHE_ALIGN, NULL);
40+
raw_dirent_slab = KMEM_CACHE(jffs2_raw_dirent, SLAB_HWCACHE_ALIGN);
4541
if (!raw_dirent_slab)
4642
goto err;
4743

48-
raw_inode_slab = kmem_cache_create("jffs2_raw_inode",
49-
sizeof(struct jffs2_raw_inode),
50-
0, SLAB_HWCACHE_ALIGN, NULL);
44+
raw_inode_slab = KMEM_CACHE(jffs2_raw_inode, SLAB_HWCACHE_ALIGN);
5145
if (!raw_inode_slab)
5246
goto err;
5347

54-
tmp_dnode_info_slab = kmem_cache_create("jffs2_tmp_dnode",
55-
sizeof(struct jffs2_tmp_dnode_info),
56-
0, 0, NULL);
48+
tmp_dnode_info_slab = KMEM_CACHE(jffs2_tmp_dnode_info, 0);
5749
if (!tmp_dnode_info_slab)
5850
goto err;
5951

@@ -63,28 +55,20 @@ int __init jffs2_create_slab_caches(void)
6355
if (!raw_node_ref_slab)
6456
goto err;
6557

66-
node_frag_slab = kmem_cache_create("jffs2_node_frag",
67-
sizeof(struct jffs2_node_frag),
68-
0, 0, NULL);
58+
node_frag_slab = KMEM_CACHE(jffs2_node_frag, 0);
6959
if (!node_frag_slab)
7060
goto err;
7161

72-
inode_cache_slab = kmem_cache_create("jffs2_inode_cache",
73-
sizeof(struct jffs2_inode_cache),
74-
0, 0, NULL);
62+
inode_cache_slab = KMEM_CACHE(jffs2_inode_cache, 0);
7563
if (!inode_cache_slab)
7664
goto err;
7765

7866
#ifdef CONFIG_JFFS2_FS_XATTR
79-
xattr_datum_cache = kmem_cache_create("jffs2_xattr_datum",
80-
sizeof(struct jffs2_xattr_datum),
81-
0, 0, NULL);
67+
xattr_datum_cache = KMEM_CACHE(jffs2_xattr_datum, 0);
8268
if (!xattr_datum_cache)
8369
goto err;
8470

85-
xattr_ref_cache = kmem_cache_create("jffs2_xattr_ref",
86-
sizeof(struct jffs2_xattr_ref),
87-
0, 0, NULL);
71+
xattr_ref_cache = KMEM_CACHE(jffs2_xattr_ref, 0);
8872
if (!xattr_ref_cache)
8973
goto err;
9074
#endif

0 commit comments

Comments
 (0)