diff options
Diffstat (limited to 'fs/jffs2/malloc.c')
-rw-r--r-- | fs/jffs2/malloc.c | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c index 036cbd11c004..3d5b7ecfbf8d 100644 --- a/fs/jffs2/malloc.c +++ b/fs/jffs2/malloc.c | |||
@@ -26,6 +26,10 @@ static kmem_cache_t *tmp_dnode_info_slab; | |||
26 | static kmem_cache_t *raw_node_ref_slab; | 26 | static kmem_cache_t *raw_node_ref_slab; |
27 | static kmem_cache_t *node_frag_slab; | 27 | static kmem_cache_t *node_frag_slab; |
28 | static kmem_cache_t *inode_cache_slab; | 28 | static kmem_cache_t *inode_cache_slab; |
29 | #ifdef CONFIG_JFFS2_FS_XATTR | ||
30 | static kmem_cache_t *xattr_datum_cache; | ||
31 | static kmem_cache_t *xattr_ref_cache; | ||
32 | #endif | ||
29 | 33 | ||
30 | int __init jffs2_create_slab_caches(void) | 34 | int __init jffs2_create_slab_caches(void) |
31 | { | 35 | { |
@@ -68,8 +72,24 @@ int __init jffs2_create_slab_caches(void) | |||
68 | inode_cache_slab = kmem_cache_create("jffs2_inode_cache", | 72 | inode_cache_slab = kmem_cache_create("jffs2_inode_cache", |
69 | sizeof(struct jffs2_inode_cache), | 73 | sizeof(struct jffs2_inode_cache), |
70 | 0, 0, NULL, NULL); | 74 | 0, 0, NULL, NULL); |
71 | if (inode_cache_slab) | 75 | if (!inode_cache_slab) |
72 | return 0; | 76 | goto err; |
77 | |||
78 | #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, NULL); | ||
82 | if (!xattr_datum_cache) | ||
83 | goto err; | ||
84 | |||
85 | xattr_ref_cache = kmem_cache_create("jffs2_xattr_ref", | ||
86 | sizeof(struct jffs2_xattr_ref), | ||
87 | 0, 0, NULL, NULL); | ||
88 | if (!xattr_ref_cache) | ||
89 | goto err; | ||
90 | #endif | ||
91 | |||
92 | return 0; | ||
73 | err: | 93 | err: |
74 | jffs2_destroy_slab_caches(); | 94 | jffs2_destroy_slab_caches(); |
75 | return -ENOMEM; | 95 | return -ENOMEM; |
@@ -91,6 +111,12 @@ void jffs2_destroy_slab_caches(void) | |||
91 | kmem_cache_destroy(node_frag_slab); | 111 | kmem_cache_destroy(node_frag_slab); |
92 | if(inode_cache_slab) | 112 | if(inode_cache_slab) |
93 | kmem_cache_destroy(inode_cache_slab); | 113 | kmem_cache_destroy(inode_cache_slab); |
114 | #ifdef CONFIG_JFFS2_FS_XATTR | ||
115 | if (xattr_datum_cache) | ||
116 | kmem_cache_destroy(xattr_datum_cache); | ||
117 | if (xattr_ref_cache) | ||
118 | kmem_cache_destroy(xattr_ref_cache); | ||
119 | #endif | ||
94 | } | 120 | } |
95 | 121 | ||
96 | struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize) | 122 | struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize) |
@@ -205,3 +231,41 @@ void jffs2_free_inode_cache(struct jffs2_inode_cache *x) | |||
205 | dbg_memalloc("%p\n", x); | 231 | dbg_memalloc("%p\n", x); |
206 | kmem_cache_free(inode_cache_slab, x); | 232 | kmem_cache_free(inode_cache_slab, x); |
207 | } | 233 | } |
234 | |||
235 | #ifdef CONFIG_JFFS2_FS_XATTR | ||
236 | struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void) | ||
237 | { | ||
238 | struct jffs2_xattr_datum *xd; | ||
239 | xd = kmem_cache_alloc(xattr_datum_cache, GFP_KERNEL); | ||
240 | dbg_memalloc("%p\n", xd); | ||
241 | |||
242 | memset(xd, 0, sizeof(struct jffs2_xattr_datum)); | ||
243 | xd->class = RAWNODE_CLASS_XATTR_DATUM; | ||
244 | INIT_LIST_HEAD(&xd->xindex); | ||
245 | return xd; | ||
246 | } | ||
247 | |||
248 | void jffs2_free_xattr_datum(struct jffs2_xattr_datum *xd) | ||
249 | { | ||
250 | dbg_memalloc("%p\n", xd); | ||
251 | kmem_cache_free(xattr_datum_cache, xd); | ||
252 | } | ||
253 | |||
254 | struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void) | ||
255 | { | ||
256 | struct jffs2_xattr_ref *ref; | ||
257 | ref = kmem_cache_alloc(xattr_ref_cache, GFP_KERNEL); | ||
258 | dbg_memalloc("%p\n", ref); | ||
259 | |||
260 | memset(ref, 0, sizeof(struct jffs2_xattr_ref)); | ||
261 | ref->class = RAWNODE_CLASS_XATTR_REF; | ||
262 | INIT_LIST_HEAD(&ref->ilist); | ||
263 | return ref; | ||
264 | } | ||
265 | |||
266 | void jffs2_free_xattr_ref(struct jffs2_xattr_ref *ref) | ||
267 | { | ||
268 | dbg_memalloc("%p\n", ref); | ||
269 | kmem_cache_free(xattr_ref_cache, ref); | ||
270 | } | ||
271 | #endif | ||