aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/nodelist.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/nodelist.h')
-rw-r--r--fs/jffs2/nodelist.h58
1 files changed, 7 insertions, 51 deletions
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 94ef88787347..80d1fda2212b 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -82,7 +82,10 @@ struct jffs2_raw_node_ref
82 word so you know when you've got there :) */ 82 word so you know when you've got there :) */
83 struct jffs2_raw_node_ref *next_phys; 83 struct jffs2_raw_node_ref *next_phys;
84 uint32_t flash_offset; 84 uint32_t flash_offset;
85#define TEST_TOTLEN
86#ifdef TEST_TOTLEN
85 uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */ 87 uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */
88#endif
86}; 89};
87 90
88 /* flash_offset & 3 always has to be zero, because nodes are 91 /* flash_offset & 3 always has to be zero, because nodes are
@@ -221,57 +224,7 @@ static inline int jffs2_blocks_use_vmalloc(struct jffs2_sb_info *c)
221 return ((c->flash_size / c->sector_size) * sizeof (struct jffs2_eraseblock)) > (128 * 1024); 224 return ((c->flash_size / c->sector_size) * sizeof (struct jffs2_eraseblock)) > (128 * 1024);
222} 225}
223 226
224/* Calculate totlen from surrounding nodes or eraseblock */ 227#define ref_totlen(a, b, c) __jffs2_ref_totlen((a), (b), (c))
225static inline uint32_t __ref_totlen(struct jffs2_sb_info *c,
226 struct jffs2_eraseblock *jeb,
227 struct jffs2_raw_node_ref *ref)
228{
229 uint32_t ref_end;
230
231 if (ref->next_phys)
232 ref_end = ref_offset(ref->next_phys);
233 else {
234 if (!jeb)
235 jeb = &c->blocks[ref->flash_offset / c->sector_size];
236
237 /* Last node in block. Use free_space */
238 BUG_ON(ref != jeb->last_node);
239 ref_end = jeb->offset + c->sector_size - jeb->free_size;
240 }
241 return ref_end - ref_offset(ref);
242}
243
244static inline uint32_t ref_totlen(struct jffs2_sb_info *c,
245 struct jffs2_eraseblock *jeb,
246 struct jffs2_raw_node_ref *ref)
247{
248 uint32_t ret;
249
250#if CONFIG_JFFS2_FS_DEBUG > 0
251 if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) {
252 printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n",
253 jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref));
254 BUG();
255 }
256#endif
257
258#if 1
259 ret = ref->__totlen;
260#else
261 /* This doesn't actually work yet */
262 ret = __ref_totlen(c, jeb, ref);
263 if (ret != ref->__totlen) {
264 printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n",
265 ref, ref_offset(ref), ref_offset(ref)+ref->__totlen,
266 ret, ref->__totlen);
267 if (!jeb)
268 jeb = &c->blocks[ref->flash_offset / c->sector_size];
269 jffs2_dbg_dump_node_refs_nolock(c, jeb);
270 BUG();
271 }
272#endif
273 return ret;
274}
275 228
276#define ALLOC_NORMAL 0 /* Normal allocation */ 229#define ALLOC_NORMAL 0 /* Normal allocation */
277#define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ 230#define ALLOC_DELETION 1 /* Deletion node. Best to allow it */
@@ -355,6 +308,9 @@ void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uin
355int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); 308int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn);
356void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 309void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
357 struct jffs2_raw_node_ref *ref, uint32_t len); 310 struct jffs2_raw_node_ref *ref, uint32_t len);
311extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c,
312 struct jffs2_eraseblock *jeb,
313 struct jffs2_raw_node_ref *ref);
358 314
359/* nodemgmt.c */ 315/* nodemgmt.c */
360int jffs2_thread_should_wake(struct jffs2_sb_info *c); 316int jffs2_thread_should_wake(struct jffs2_sb_info *c);