diff options
author | Artem B. Bityutskiy <dedekind@infradead.org> | 2005-07-17 02:56:26 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-11-06 10:21:25 -0500 |
commit | 730554d94607572ef8300c5c9848540b42394897 (patch) | |
tree | fcefe9225afae333e09a59bdb2b8ac6e44676ce6 /fs/jffs2/nodelist.h | |
parent | dae6227f71fedb40b2478d3062397d3ab54e7556 (diff) |
[JFFS2] Debug code clean up - step 1
Move debug functions into a seperate source file
Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/nodelist.h')
-rw-r--r-- | fs/jffs2/nodelist.h | 106 |
1 files changed, 9 insertions, 97 deletions
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index b34c397909ef..6802e0968d3e 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: nodelist.h,v 1.131 2005/07/05 21:03:07 dwmw2 Exp $ | 10 | * $Id: nodelist.h,v 1.132 2005/07/17 06:56:21 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -24,26 +24,10 @@ | |||
24 | #ifdef __ECOS | 24 | #ifdef __ECOS |
25 | #include "os-ecos.h" | 25 | #include "os-ecos.h" |
26 | #else | 26 | #else |
27 | #include <linux/mtd/compatmac.h> /* For min/max in older kernels */ | 27 | #include <linux/mtd/compatmac.h> /* For compatibility with older kernels */ |
28 | #include "os-linux.h" | 28 | #include "os-linux.h" |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifndef CONFIG_JFFS2_FS_DEBUG | ||
32 | #define CONFIG_JFFS2_FS_DEBUG 1 | ||
33 | #endif | ||
34 | |||
35 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
36 | #define D1(x) x | ||
37 | #else | ||
38 | #define D1(x) | ||
39 | #endif | ||
40 | |||
41 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
42 | #define D2(x) x | ||
43 | #else | ||
44 | #define D2(x) | ||
45 | #endif | ||
46 | |||
47 | #define JFFS2_NATIVE_ENDIAN | 31 | #define JFFS2_NATIVE_ENDIAN |
48 | 32 | ||
49 | /* Note we handle mode bits conversion from JFFS2 (i.e. Linux) to/from | 33 | /* Note we handle mode bits conversion from JFFS2 (i.e. Linux) to/from |
@@ -207,79 +191,6 @@ struct jffs2_eraseblock | |||
207 | struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */ | 191 | struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */ |
208 | }; | 192 | }; |
209 | 193 | ||
210 | #define ACCT_SANITY_CHECK(c, jeb) do { \ | ||
211 | struct jffs2_eraseblock *___j = jeb; \ | ||
212 | if ((___j) && ___j->used_size + ___j->dirty_size + ___j->free_size + ___j->wasted_size + ___j->unchecked_size != c->sector_size) { \ | ||
213 | printk(KERN_NOTICE "Eeep. Space accounting for block at 0x%08x is screwed\n", ___j->offset); \ | ||
214 | printk(KERN_NOTICE "free 0x%08x + dirty 0x%08x + used %08x + wasted %08x + unchecked %08x != total %08x\n", \ | ||
215 | ___j->free_size, ___j->dirty_size, ___j->used_size, ___j->wasted_size, ___j->unchecked_size, c->sector_size); \ | ||
216 | BUG(); \ | ||
217 | } \ | ||
218 | if (c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size + c->wasted_size + c->unchecked_size != c->flash_size) { \ | ||
219 | printk(KERN_NOTICE "Eeep. Space accounting superblock info is screwed\n"); \ | ||
220 | printk(KERN_NOTICE "free 0x%08x + dirty 0x%08x + used %08x + erasing %08x + bad %08x + wasted %08x + unchecked %08x != total %08x\n", \ | ||
221 | c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, c->wasted_size, c->unchecked_size, c->flash_size); \ | ||
222 | BUG(); \ | ||
223 | } \ | ||
224 | } while(0) | ||
225 | |||
226 | static inline void paranoia_failed_dump(struct jffs2_eraseblock *jeb) | ||
227 | { | ||
228 | struct jffs2_raw_node_ref *ref; | ||
229 | int i=0; | ||
230 | |||
231 | printk(KERN_NOTICE); | ||
232 | for (ref = jeb->first_node; ref; ref = ref->next_phys) { | ||
233 | printk("%08x->", ref_offset(ref)); | ||
234 | if (++i == 8) { | ||
235 | i = 0; | ||
236 | printk("\n" KERN_NOTICE); | ||
237 | } | ||
238 | } | ||
239 | printk("\n"); | ||
240 | } | ||
241 | |||
242 | |||
243 | #define ACCT_PARANOIA_CHECK(jeb) do { \ | ||
244 | uint32_t my_used_size = 0; \ | ||
245 | uint32_t my_unchecked_size = 0; \ | ||
246 | struct jffs2_raw_node_ref *ref2 = jeb->first_node; \ | ||
247 | while (ref2) { \ | ||
248 | if (unlikely(ref2->flash_offset < jeb->offset || \ | ||
249 | ref2->flash_offset > jeb->offset + c->sector_size)) { \ | ||
250 | printk(KERN_NOTICE "Node %08x shouldn't be in block at %08x!\n", \ | ||
251 | ref_offset(ref2), jeb->offset); \ | ||
252 | paranoia_failed_dump(jeb); \ | ||
253 | BUG(); \ | ||
254 | } \ | ||
255 | if (ref_flags(ref2) == REF_UNCHECKED) \ | ||
256 | my_unchecked_size += ref_totlen(c, jeb, ref2); \ | ||
257 | else if (!ref_obsolete(ref2)) \ | ||
258 | my_used_size += ref_totlen(c, jeb, ref2); \ | ||
259 | if (unlikely((!ref2->next_phys) != (ref2 == jeb->last_node))) { \ | ||
260 | if (!ref2->next_phys) \ | ||
261 | printk("ref for node at %p (phys %08x) has next_phys->%p (----), last_node->%p (phys %08x)\n", \ | ||
262 | ref2, ref_offset(ref2), ref2->next_phys, \ | ||
263 | jeb->last_node, ref_offset(jeb->last_node)); \ | ||
264 | else \ | ||
265 | printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \ | ||
266 | ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \ | ||
267 | jeb->last_node, ref_offset(jeb->last_node)); \ | ||
268 | paranoia_failed_dump(jeb); \ | ||
269 | BUG(); \ | ||
270 | } \ | ||
271 | ref2 = ref2->next_phys; \ | ||
272 | } \ | ||
273 | if (my_used_size != jeb->used_size) { \ | ||
274 | printk(KERN_NOTICE "Calculated used size %08x != stored used size %08x\n", my_used_size, jeb->used_size); \ | ||
275 | BUG(); \ | ||
276 | } \ | ||
277 | if (my_unchecked_size != jeb->unchecked_size) { \ | ||
278 | printk(KERN_NOTICE "Calculated unchecked size %08x != stored unchecked size %08x\n", my_unchecked_size, jeb->unchecked_size); \ | ||
279 | BUG(); \ | ||
280 | } \ | ||
281 | } while(0) | ||
282 | |||
283 | /* Calculate totlen from surrounding nodes or eraseblock */ | 194 | /* Calculate totlen from surrounding nodes or eraseblock */ |
284 | static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | 195 | static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, |
285 | struct jffs2_eraseblock *jeb, | 196 | struct jffs2_eraseblock *jeb, |
@@ -306,11 +217,13 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | |||
306 | { | 217 | { |
307 | uint32_t ret; | 218 | uint32_t ret; |
308 | 219 | ||
309 | D1(if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) { | 220 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
221 | if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) { | ||
310 | printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n", | 222 | printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n", |
311 | jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref)); | 223 | jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref)); |
312 | BUG(); | 224 | BUG(); |
313 | }) | 225 | } |
226 | #endif | ||
314 | 227 | ||
315 | #if 1 | 228 | #if 1 |
316 | ret = ref->__totlen; | 229 | ret = ref->__totlen; |
@@ -323,14 +236,13 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | |||
323 | ret, ref->__totlen); | 236 | ret, ref->__totlen); |
324 | if (!jeb) | 237 | if (!jeb) |
325 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 238 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
326 | paranoia_failed_dump(jeb); | 239 | jffs2_dbg_dump_node_refs(c, jeb); |
327 | BUG(); | 240 | BUG(); |
328 | } | 241 | } |
329 | #endif | 242 | #endif |
330 | return ret; | 243 | return ret; |
331 | } | 244 | } |
332 | 245 | ||
333 | |||
334 | #define ALLOC_NORMAL 0 /* Normal allocation */ | 246 | #define ALLOC_NORMAL 0 /* Normal allocation */ |
335 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ | 247 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ |
336 | #define ALLOC_GC 2 /* Space requested for GC. Give it or die */ | 248 | #define ALLOC_GC 2 /* Space requested for GC. Give it or die */ |
@@ -384,7 +296,6 @@ static inline struct jffs2_node_frag *frag_last(struct rb_root *root) | |||
384 | #define frag_erase(frag, list) rb_erase(&frag->rb, list); | 296 | #define frag_erase(frag, list) rb_erase(&frag->rb, list); |
385 | 297 | ||
386 | /* nodelist.c */ | 298 | /* nodelist.c */ |
387 | D2(void jffs2_print_frag_list(struct jffs2_inode_info *f)); | ||
388 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list); | 299 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list); |
389 | int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 300 | int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
390 | struct rb_root *tnp, struct jffs2_full_dirent **fdp, | 301 | struct rb_root *tnp, struct jffs2_full_dirent **fdp, |
@@ -410,7 +321,6 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t * | |||
410 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); | 321 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); |
411 | void jffs2_complete_reservation(struct jffs2_sb_info *c); | 322 | void jffs2_complete_reservation(struct jffs2_sb_info *c); |
412 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); | 323 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); |
413 | void jffs2_dump_block_lists(struct jffs2_sb_info *c); | ||
414 | 324 | ||
415 | /* write.c */ | 325 | /* write.c */ |
416 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); | 326 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); |
@@ -483,4 +393,6 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
483 | int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | 393 | int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
484 | #endif | 394 | #endif |
485 | 395 | ||
396 | #include "debug.h" | ||
397 | |||
486 | #endif /* __JFFS2_NODELIST_H__ */ | 398 | #endif /* __JFFS2_NODELIST_H__ */ |