aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/readinode.c
diff options
context:
space:
mode:
authorArtem B. Bityutskiy <dedekind@infradead.org>2005-07-17 02:56:26 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 10:21:25 -0500
commit730554d94607572ef8300c5c9848540b42394897 (patch)
treefcefe9225afae333e09a59bdb2b8ac6e44676ce6 /fs/jffs2/readinode.c
parentdae6227f71fedb40b2478d3062397d3ab54e7556 (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/readinode.c')
-rw-r--r--fs/jffs2/readinode.c110
1 files changed, 4 insertions, 106 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 5b2a83599d73..cf39bcf3e3cf 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -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: readinode.c,v 1.125 2005/07/10 13:13:55 dedekind Exp $ 10 * $Id: readinode.c,v 1.126 2005/07/17 06:56:21 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -22,104 +22,6 @@
22 22
23static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag); 23static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag);
24 24
25#if CONFIG_JFFS2_FS_DEBUG >= 2
26static void jffs2_print_fragtree(struct rb_root *list, int permitbug)
27{
28 struct jffs2_node_frag *this = frag_first(list);
29 uint32_t lastofs = 0;
30 int buggy = 0;
31
32 while(this) {
33 if (this->node)
34 printk(KERN_DEBUG "frag %04x-%04x: 0x%08x(%d) on flash (*%p). left (%p), right (%p), parent (%p)\n",
35 this->ofs, this->ofs+this->size, ref_offset(this->node->raw), ref_flags(this->node->raw),
36 this, frag_left(this), frag_right(this), frag_parent(this));
37 else
38 printk(KERN_DEBUG "frag %04x-%04x: hole (*%p). left (%p} right (%p), parent (%p)\n", this->ofs,
39 this->ofs+this->size, this, frag_left(this), frag_right(this), frag_parent(this));
40 if (this->ofs != lastofs)
41 buggy = 1;
42 lastofs = this->ofs+this->size;
43 this = frag_next(this);
44 }
45 if (buggy && !permitbug) {
46 printk(KERN_CRIT "Frag tree got a hole in it\n");
47 BUG();
48 }
49}
50
51void jffs2_print_frag_list(struct jffs2_inode_info *f)
52{
53 jffs2_print_fragtree(&f->fragtree, 0);
54
55 if (f->metadata) {
56 printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
57 }
58}
59#endif
60
61#if CONFIG_JFFS2_FS_DEBUG >= 1
62static int jffs2_sanitycheck_fragtree(struct jffs2_inode_info *f)
63{
64 struct jffs2_node_frag *frag;
65 int bitched = 0;
66
67 for (frag = frag_first(&f->fragtree); frag; frag = frag_next(frag)) {
68
69 struct jffs2_full_dnode *fn = frag->node;
70 if (!fn || !fn->raw)
71 continue;
72
73 if (ref_flags(fn->raw) == REF_PRISTINE) {
74
75 if (fn->frags > 1) {
76 printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2\n", ref_offset(fn->raw), fn->frags);
77 bitched = 1;
78 }
79 /* A hole node which isn't multi-page should be garbage-collected
80 and merged anyway, so we just check for the frag size here,
81 rather than mucking around with actually reading the node
82 and checking the compression type, which is the real way
83 to tell a hole node. */
84 if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) {
85 printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2\n",
86 ref_offset(fn->raw));
87 bitched = 1;
88 }
89
90 if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) {
91 printk(KERN_WARNING "REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2\n",
92 ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size);
93 bitched = 1;
94 }
95 }
96 }
97
98 if (bitched) {
99 struct jffs2_node_frag *thisfrag;
100
101 printk(KERN_WARNING "Inode is #%u\n", f->inocache->ino);
102 thisfrag = frag_first(&f->fragtree);
103 while (thisfrag) {
104 if (!thisfrag->node) {
105 printk("Frag @0x%x-0x%x; node-less hole\n",
106 thisfrag->ofs, thisfrag->size + thisfrag->ofs);
107 } else if (!thisfrag->node->raw) {
108 printk("Frag @0x%x-0x%x; raw-less hole\n",
109 thisfrag->ofs, thisfrag->size + thisfrag->ofs);
110 } else {
111 printk("Frag @0x%x-0x%x; raw at 0x%08x(%d) (0x%x-0x%x)\n",
112 thisfrag->ofs, thisfrag->size + thisfrag->ofs,
113 ref_offset(thisfrag->node->raw), ref_flags(thisfrag->node->raw),
114 thisfrag->node->ofs, thisfrag->node->ofs+thisfrag->node->size);
115 }
116 thisfrag = frag_next(thisfrag);
117 }
118 }
119 return bitched;
120}
121#endif /* D1 */
122
123static void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this) 25static void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this)
124{ 26{
125 if (this->node) { 27 if (this->node) {
@@ -190,12 +92,8 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
190 mark_ref_normal(next->node->raw); 92 mark_ref_normal(next->node->raw);
191 } 93 }
192 } 94 }
193 D2(if (jffs2_sanitycheck_fragtree(f)) { 95 D2(jffs2_dbg_fragtree_paranoia_check(f));
194 printk(KERN_WARNING "Just added node %04x-%04x @0x%08x on flash, newfrag *%p\n", 96 D2(jffs2_dbg_dump_fragtree(f));
195 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
196 return 0;
197 })
198 D2(jffs2_print_frag_list(f));
199 return 0; 97 return 0;
200} 98}
201 99
@@ -582,7 +480,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
582 480
583 jffs2_free_tmp_dnode_info(tn); 481 jffs2_free_tmp_dnode_info(tn);
584 } 482 }
585 D1(jffs2_sanitycheck_fragtree(f)); 483 jffs2_dbg_fragtree_paranoia_check(f);
586 484
587 if (!fn) { 485 if (!fn) {
588 /* No data nodes for this inode. */ 486 /* No data nodes for this inode. */