77 *
88 * For licensing information, see the file 'LICENCE' in this directory.
99 *
10- * $Id: malloc.c,v 1.28 2004/11/16 20:36:11 dwmw2 Exp $
10+ * $Id: malloc.c,v 1.29 2005/07/27 14:16:53 dedekind Exp $
1111 *
1212 */
1313
1717#include <linux/jffs2.h>
1818#include "nodelist.h"
1919
20- #if 0
21- #define JFFS2_SLAB_POISON SLAB_POISON
22- #else
23- #define JFFS2_SLAB_POISON 0
24- #endif
25-
26- // replace this by #define D3 (x) x for cache debugging
27- #define D3 (x )
28-
2920/* These are initialised to NULL in the kernel startup code.
3021 If you're porting to other operating systems, beware */
3122static kmem_cache_t * full_dnode_slab ;
@@ -40,43 +31,43 @@ int __init jffs2_create_slab_caches(void)
4031{
4132 full_dnode_slab = kmem_cache_create ("jffs2_full_dnode" ,
4233 sizeof (struct jffs2_full_dnode ),
43- 0 , JFFS2_SLAB_POISON , NULL , NULL );
34+ 0 , 0 , NULL , NULL );
4435 if (!full_dnode_slab )
4536 goto err ;
4637
4738 raw_dirent_slab = kmem_cache_create ("jffs2_raw_dirent" ,
4839 sizeof (struct jffs2_raw_dirent ),
49- 0 , JFFS2_SLAB_POISON , NULL , NULL );
40+ 0 , 0 , NULL , NULL );
5041 if (!raw_dirent_slab )
5142 goto err ;
5243
5344 raw_inode_slab = kmem_cache_create ("jffs2_raw_inode" ,
5445 sizeof (struct jffs2_raw_inode ),
55- 0 , JFFS2_SLAB_POISON , NULL , NULL );
46+ 0 , 0 , NULL , NULL );
5647 if (!raw_inode_slab )
5748 goto err ;
5849
5950 tmp_dnode_info_slab = kmem_cache_create ("jffs2_tmp_dnode" ,
6051 sizeof (struct jffs2_tmp_dnode_info ),
61- 0 , JFFS2_SLAB_POISON , NULL , NULL );
52+ 0 , 0 , NULL , NULL );
6253 if (!tmp_dnode_info_slab )
6354 goto err ;
6455
6556 raw_node_ref_slab = kmem_cache_create ("jffs2_raw_node_ref" ,
6657 sizeof (struct jffs2_raw_node_ref ),
67- 0 , JFFS2_SLAB_POISON , NULL , NULL );
58+ 0 , 0 , NULL , NULL );
6859 if (!raw_node_ref_slab )
6960 goto err ;
7061
7162 node_frag_slab = kmem_cache_create ("jffs2_node_frag" ,
7263 sizeof (struct jffs2_node_frag ),
73- 0 , JFFS2_SLAB_POISON , NULL , NULL );
64+ 0 , 0 , NULL , NULL );
7465 if (!node_frag_slab )
7566 goto err ;
7667
7768 inode_cache_slab = kmem_cache_create ("jffs2_inode_cache" ,
7869 sizeof (struct jffs2_inode_cache ),
79- 0 , JFFS2_SLAB_POISON , NULL , NULL );
70+ 0 , 0 , NULL , NULL );
8071 if (inode_cache_slab )
8172 return 0 ;
8273 err :
@@ -104,102 +95,113 @@ void jffs2_destroy_slab_caches(void)
10495
10596struct jffs2_full_dirent * jffs2_alloc_full_dirent (int namesize )
10697{
107- return kmalloc (sizeof (struct jffs2_full_dirent ) + namesize , GFP_KERNEL );
98+ struct jffs2_full_dirent * ret ;
99+ ret = kmalloc (sizeof (struct jffs2_full_dirent ) + namesize , GFP_KERNEL );
100+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
101+ return ret ;
108102}
109103
110104void jffs2_free_full_dirent (struct jffs2_full_dirent * x )
111105{
106+ JFFS2_DBG_MEMALLOC ("%p\n" , x );
112107 kfree (x );
113108}
114109
115110struct jffs2_full_dnode * jffs2_alloc_full_dnode (void )
116111{
117- struct jffs2_full_dnode * ret = kmem_cache_alloc (full_dnode_slab , GFP_KERNEL );
118- D3 (printk (KERN_DEBUG "alloc_full_dnode at %p\n" , ret ));
112+ struct jffs2_full_dnode * ret ;
113+ ret = kmem_cache_alloc (full_dnode_slab , GFP_KERNEL );
114+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
119115 return ret ;
120116}
121117
122118void jffs2_free_full_dnode (struct jffs2_full_dnode * x )
123119{
124- D3 ( printk ( KERN_DEBUG "free full_dnode at %p\n" , x ) );
120+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
125121 kmem_cache_free (full_dnode_slab , x );
126122}
127123
128124struct jffs2_raw_dirent * jffs2_alloc_raw_dirent (void )
129125{
130- struct jffs2_raw_dirent * ret = kmem_cache_alloc (raw_dirent_slab , GFP_KERNEL );
131- D3 (printk (KERN_DEBUG "alloc_raw_dirent\n" , ret ));
126+ struct jffs2_raw_dirent * ret ;
127+ ret = kmem_cache_alloc (raw_dirent_slab , GFP_KERNEL );
128+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
132129 return ret ;
133130}
134131
135132void jffs2_free_raw_dirent (struct jffs2_raw_dirent * x )
136133{
137- D3 ( printk ( KERN_DEBUG "free_raw_dirent at %p\n" , x ) );
134+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
138135 kmem_cache_free (raw_dirent_slab , x );
139136}
140137
141138struct jffs2_raw_inode * jffs2_alloc_raw_inode (void )
142139{
143- struct jffs2_raw_inode * ret = kmem_cache_alloc (raw_inode_slab , GFP_KERNEL );
144- D3 (printk (KERN_DEBUG "alloc_raw_inode at %p\n" , ret ));
140+ struct jffs2_raw_inode * ret ;
141+ ret = kmem_cache_alloc (raw_inode_slab , GFP_KERNEL );
142+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
145143 return ret ;
146144}
147145
148146void jffs2_free_raw_inode (struct jffs2_raw_inode * x )
149147{
150- D3 ( printk ( KERN_DEBUG "free_raw_inode at %p\n" , x ) );
148+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
151149 kmem_cache_free (raw_inode_slab , x );
152150}
153151
154152struct jffs2_tmp_dnode_info * jffs2_alloc_tmp_dnode_info (void )
155153{
156- struct jffs2_tmp_dnode_info * ret = kmem_cache_alloc (tmp_dnode_info_slab , GFP_KERNEL );
157- D3 (printk (KERN_DEBUG "alloc_tmp_dnode_info at %p\n" , ret ));
154+ struct jffs2_tmp_dnode_info * ret ;
155+ ret = kmem_cache_alloc (tmp_dnode_info_slab , GFP_KERNEL );
156+ JFFS2_DBG_MEMALLOC ("%p\n" ,
157+ ret );
158158 return ret ;
159159}
160160
161161void jffs2_free_tmp_dnode_info (struct jffs2_tmp_dnode_info * x )
162162{
163- D3 ( printk ( KERN_DEBUG "free_tmp_dnode_info at %p\n" , x ) );
163+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
164164 kmem_cache_free (tmp_dnode_info_slab , x );
165165}
166166
167167struct jffs2_raw_node_ref * jffs2_alloc_raw_node_ref (void )
168168{
169- struct jffs2_raw_node_ref * ret = kmem_cache_alloc (raw_node_ref_slab , GFP_KERNEL );
170- D3 (printk (KERN_DEBUG "alloc_raw_node_ref at %p\n" , ret ));
169+ struct jffs2_raw_node_ref * ret ;
170+ ret = kmem_cache_alloc (raw_node_ref_slab , GFP_KERNEL );
171+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
171172 return ret ;
172173}
173174
174175void jffs2_free_raw_node_ref (struct jffs2_raw_node_ref * x )
175176{
176- D3 ( printk ( KERN_DEBUG "free_raw_node_ref at %p\n" , x ) );
177+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
177178 kmem_cache_free (raw_node_ref_slab , x );
178179}
179180
180181struct jffs2_node_frag * jffs2_alloc_node_frag (void )
181182{
182- struct jffs2_node_frag * ret = kmem_cache_alloc (node_frag_slab , GFP_KERNEL );
183- D3 (printk (KERN_DEBUG "alloc_node_frag at %p\n" , ret ));
183+ struct jffs2_node_frag * ret ;
184+ ret = kmem_cache_alloc (node_frag_slab , GFP_KERNEL );
185+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
184186 return ret ;
185187}
186188
187189void jffs2_free_node_frag (struct jffs2_node_frag * x )
188190{
189- D3 ( printk ( KERN_DEBUG "free_node_frag at %p\n" , x ) );
191+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
190192 kmem_cache_free (node_frag_slab , x );
191193}
192194
193195struct jffs2_inode_cache * jffs2_alloc_inode_cache (void )
194196{
195- struct jffs2_inode_cache * ret = kmem_cache_alloc (inode_cache_slab , GFP_KERNEL );
196- D3 (printk (KERN_DEBUG "Allocated inocache at %p\n" , ret ));
197+ struct jffs2_inode_cache * ret ;
198+ ret = kmem_cache_alloc (inode_cache_slab , GFP_KERNEL );
199+ JFFS2_DBG_MEMALLOC ("%p\n" , ret );
197200 return ret ;
198201}
199202
200203void jffs2_free_inode_cache (struct jffs2_inode_cache * x )
201204{
202- D3 ( printk ( KERN_DEBUG "Freeing inocache at %p\n" , x ) );
205+ JFFS2_DBG_MEMALLOC ( " %p\n" , x );
203206 kmem_cache_free (inode_cache_slab , x );
204207}
205-
0 commit comments