aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/malloc.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-23 21:04:45 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-23 21:04:45 -0400
commit2f785402f39b96a077b6e62bf26164bfb8e0c980 (patch)
tree3f3a38b484ef2dabda1599d4d8f08b121bd03a76 /fs/jffs2/malloc.c
parent4cbb9b80e171107c6c34116283fe38e5a396c68b (diff)
[JFFS2] Reduce visibility of raw_node_ref to upper layers of JFFS2 code.
As the first step towards eliminating the ref->next_phys member and saving memory by using an _array_ of struct jffs2_raw_node_ref per eraseblock, stop the write functions from allocating their own refs; have them just _reserve_ the appropriate number instead. Then jffs2_link_node_ref() can just fill them in. Use a linked list of pre-allocated refs in the superblock, for now. Once we switch to an array, it'll just be a case of extending that array. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/malloc.c')
-rw-r--r--fs/jffs2/malloc.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index f2473fa2fd16..3df3250314a2 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -190,7 +190,29 @@ void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x)
190 kmem_cache_free(tmp_dnode_info_slab, x); 190 kmem_cache_free(tmp_dnode_info_slab, x);
191} 191}
192 192
193struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void) 193int jffs2_prealloc_raw_node_refs(struct jffs2_sb_info *c, int nr)
194{
195 struct jffs2_raw_node_ref *p = c->refs;
196
197 dbg_memalloc("%d\n", nr);
198
199 while (nr && p) {
200 p = p->next_in_ino;
201 nr--;
202 }
203 while (nr) {
204 p = __jffs2_alloc_raw_node_ref();
205 if (!p)
206 return -ENOMEM;
207 p->next_in_ino = c->refs;
208 c->refs = p;
209 nr--;
210 }
211 c->reserved_refs = nr;
212 return 0;
213}
214
215struct jffs2_raw_node_ref *__jffs2_alloc_raw_node_ref(void)
194{ 216{
195 struct jffs2_raw_node_ref *ret; 217 struct jffs2_raw_node_ref *ret;
196 ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); 218 ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL);
@@ -198,7 +220,7 @@ struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void)
198 return ret; 220 return ret;
199} 221}
200 222
201void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) 223void __jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x)
202{ 224{
203 dbg_memalloc("%p\n", x); 225 dbg_memalloc("%p\n", x);
204 kmem_cache_free(raw_node_ref_slab, x); 226 kmem_cache_free(raw_node_ref_slab, x);