Commit e0c8e42f authored by Artem B. Bityutskiy's avatar Artem B. Bityutskiy Committed by Thomas Gleixner

[JFFS2] Debug code clean up - step 3

Various simplifiactions. printk format corrections.
Convert more code to use the new debug functions.
Signed-off-by: default avatarArtem B. Bityutskiy <dedekind@infradead.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 6dac02a5
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: build.c,v 1.74 2005/07/17 12:01:42 dedekind Exp $ * $Id: build.c,v 1.75 2005/07/22 10:32:07 dedekind Exp $
* *
*/ */
...@@ -104,7 +104,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -104,7 +104,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
goto exit; goto exit;
D1(printk(KERN_DEBUG "Scanned flash completely\n")); D1(printk(KERN_DEBUG "Scanned flash completely\n"));
D2(jffs2_dbg_dump_block_lists(c)); jffs2_dbg_dump_block_lists_nolock(c);
c->flags |= JFFS2_SB_FLAG_BUILDING; c->flags |= JFFS2_SB_FLAG_BUILDING;
/* Now scan the directory tree, increasing nlink according to every dirent found. */ /* Now scan the directory tree, increasing nlink according to every dirent found. */
...@@ -168,7 +168,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -168,7 +168,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
c->flags &= ~JFFS2_SB_FLAG_BUILDING; c->flags &= ~JFFS2_SB_FLAG_BUILDING;
D1(printk(KERN_DEBUG "Pass 3 complete\n")); D1(printk(KERN_DEBUG "Pass 3 complete\n"));
jffs2_dbg_dump_block_lists(c); jffs2_dbg_dump_block_lists_nolock(c);
/* Rotate the lists by some number to ensure wear levelling */ /* Rotate the lists by some number to ensure wear levelling */
jffs2_rotate_lists(c); jffs2_rotate_lists(c);
......
...@@ -7,18 +7,30 @@ ...@@ -7,18 +7,30 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: debug.c,v 1.1 2005/07/17 06:56:20 dedekind Exp $ * $Id: debug.c,v 1.7 2005/07/24 15:14:14 dedekind Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/crc32.h>
#include <linux/jffs2.h>
#include "nodelist.h" #include "nodelist.h"
#include "debug.h" #include "debug.h"
#ifdef JFFS2_DBG_PARANOIA_CHECKS #ifdef JFFS2_DBG_PARANOIA_CHECKS
/*
* Check the fragtree.
*/
void void
jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f)
{
down(&f->sem);
__jffs2_dbg_fragtree_paranoia_check_nolock(f);
up(&f->sem);
}
void
__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f)
{ {
struct jffs2_node_frag *frag; struct jffs2_node_frag *frag;
int bitched = 0; int bitched = 0;
...@@ -31,7 +43,7 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) ...@@ -31,7 +43,7 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f)
if (ref_flags(fn->raw) == REF_PRISTINE) { if (ref_flags(fn->raw) == REF_PRISTINE) {
if (fn->frags > 1) { if (fn->frags > 1) {
printk(KERN_ERR "REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2\n", JFFS2_ERROR("REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n",
ref_offset(fn->raw), fn->frags); ref_offset(fn->raw), fn->frags);
bitched = 1; bitched = 1;
} }
...@@ -43,15 +55,15 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) ...@@ -43,15 +55,15 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f)
to tell a hole node. */ to tell a hole node. */
if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag)
&& frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) { && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) {
printk(KERN_ERR "REF_PRISTINE node at 0x%08x had a previous non-hole frag " JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a previous non-hole frag "
"in the same page. Tell dwmw2\n", ref_offset(fn->raw)); "in the same page. Tell dwmw2.\n", ref_offset(fn->raw));
bitched = 1; bitched = 1;
} }
if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag)
&& frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) { && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) {
printk(KERN_ERR "REF_PRISTINE node at 0x%08x (%08x-%08x) had a following " JFFS2_ERROR("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following "
"non-hole frag in the same page. Tell dwmw2\n", "non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size); ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size);
bitched = 1; bitched = 1;
} }
...@@ -59,8 +71,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) ...@@ -59,8 +71,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f)
} }
if (bitched) { if (bitched) {
printk(KERN_ERR "Fragtree is corrupted. Fragtree dump:\n"); JFFS2_ERROR("fragtree is corrupted.\n");
jffs2_dbg_dump_fragtree(f); __jffs2_dbg_dump_fragtree_nolock(f);
BUG(); BUG();
} }
} }
...@@ -69,7 +81,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) ...@@ -69,7 +81,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f)
* Check if the flash contains all 0xFF before we start writing. * Check if the flash contains all 0xFF before we start writing.
*/ */
void void
jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len) __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
uint32_t ofs, int len)
{ {
size_t retlen; size_t retlen;
int ret, i; int ret, i;
...@@ -81,8 +94,8 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len ...@@ -81,8 +94,8 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len
ret = jffs2_flash_read(c, ofs, len, &retlen, buf); ret = jffs2_flash_read(c, ofs, len, &retlen, buf);
if (ret || (retlen != len)) { if (ret || (retlen != len)) {
printk(KERN_WARNING "read %d bytes failed or short in %s(). ret %d, retlen %zd\n", JFFS2_WARNING("read %d bytes failed or short. ret %d, retlen %zd.\n",
len, __FUNCTION__, ret, retlen); len, ret, retlen);
kfree(buf); kfree(buf);
return; return;
} }
...@@ -93,9 +106,9 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len ...@@ -93,9 +106,9 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len
ret = 1; ret = 1;
if (ret) { if (ret) {
printk(KERN_ERR "ARGH. About to write node to %#08x on flash, but there are data " JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data "
"already there. The first corrupted byte is at %#08x.\n", ofs, ofs + i); "already there. The first corrupted byte is at %#08x offset.\n", ofs, ofs + i);
jffs2_dbg_dump_buffer(buf, len, ofs); __jffs2_dbg_dump_buffer(buf, len, ofs);
kfree(buf); kfree(buf);
BUG(); BUG();
} }
...@@ -107,7 +120,17 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len ...@@ -107,7 +120,17 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len
* Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'. * Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'.
*/ */
void void
jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock);
}
void
__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb)
{ {
uint32_t my_used_size = 0; uint32_t my_used_size = 0;
uint32_t my_unchecked_size = 0; uint32_t my_unchecked_size = 0;
...@@ -119,11 +142,9 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock * ...@@ -119,11 +142,9 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *
if (ref2->flash_offset < jeb->offset || if (ref2->flash_offset < jeb->offset ||
ref2->flash_offset > jeb->offset + c->sector_size) { ref2->flash_offset > jeb->offset + c->sector_size) {
printk(KERN_ERR "node_ref %#08x shouldn't be in block at %#08x!\n", JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n",
ref_offset(ref2), jeb->offset); ref_offset(ref2), jeb->offset);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
if (ref_flags(ref2) == REF_UNCHECKED) if (ref_flags(ref2) == REF_UNCHECKED)
...@@ -134,69 +155,82 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock * ...@@ -134,69 +155,82 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *
my_dirty_size += totlen; my_dirty_size += totlen;
if ((!ref2->next_phys) != (ref2 == jeb->last_node)) { if ((!ref2->next_phys) != (ref2 == jeb->last_node)) {
printk(KERN_ERR "node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), " JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), "
"last_node is at %#08x (mem %p)\n", "last_node is at %#08x (mem %p).\n",
ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys, ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys,
ref_offset(jeb->last_node), jeb->last_node); ref_offset(jeb->last_node), jeb->last_node);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
ref2 = ref2->next_phys; ref2 = ref2->next_phys;
} }
if (my_used_size != jeb->used_size) { if (my_used_size != jeb->used_size) {
printk(KERN_ERR "Calculated used size %#08x != stored used size %#08x\n", JFFS2_ERROR("Calculated used size %#08x != stored used size %#08x.\n",
my_used_size, jeb->used_size); my_used_size, jeb->used_size);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
if (my_unchecked_size != jeb->unchecked_size) { if (my_unchecked_size != jeb->unchecked_size) {
printk(KERN_ERR "Calculated unchecked size %#08x != stored unchecked size %#08x\n", JFFS2_ERROR("Calculated unchecked size %#08x != stored unchecked size %#08x.\n",
my_unchecked_size, jeb->unchecked_size); my_unchecked_size, jeb->unchecked_size);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
#if 0
/* This should work when we implement ref->__totlen elemination */
if (my_dirty_size != jeb->dirty_size + jeb->wasted_size) { if (my_dirty_size != jeb->dirty_size + jeb->wasted_size) {
printk(KERN_ERR "Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n", JFFS2_ERROR("Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n",
my_dirty_size, jeb->dirty_size + jeb->wasted_size); my_dirty_size, jeb->dirty_size + jeb->wasted_size);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
if (jeb->free_size == 0 if (jeb->free_size == 0
&& my_used_size + my_unchecked_size + my_dirty_size != c->sector_size) { && my_used_size + my_unchecked_size + my_dirty_size != c->sector_size) {
printk(KERN_ERR "The sum of all nodes in block (%#x) != size of block (%#x)\n", JFFS2_ERROR("The sum of all nodes in block (%#x) != size of block (%#x)\n",
my_used_size + my_unchecked_size + my_dirty_size, my_used_size + my_unchecked_size + my_dirty_size,
c->sector_size); c->sector_size);
jffs2_dbg_dump_node_refs(c, jeb); goto error;
jffs2_dbg_dump_block_lists(c);
BUG();
} }
#endif
return;
error:
__jffs2_dbg_dump_node_refs_nolock(c, jeb);
__jffs2_dbg_dump_jeb_nolock(jeb);
__jffs2_dbg_dump_block_lists_nolock(c);
BUG();
} }
#endif /* JFFS2_PARANOIA_CHECKS */ #endif /* JFFS2_DBG_PARANOIA_CHECKS */
#if defined(JFFS2_PARANOIA_CHECKS) || (CONFIG_JFFS2_FS_DEBUG > 0) #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS)
/* /*
* Dump the node_refs of the 'jeb' JFFS2 eraseblock. * Dump the node_refs of the 'jeb' JFFS2 eraseblock.
*/ */
void void
jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_dump_node_refs_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock);
}
void
__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb)
{ {
struct jffs2_raw_node_ref *ref; struct jffs2_raw_node_ref *ref;
int i = 0; int i = 0;
JFFS2_DEBUG("Dump node_refs of the eraseblock %#08x\n", jeb->offset);
if (!jeb->first_node) { if (!jeb->first_node) {
printk(KERN_DEBUG "no nodes in block %#08x\n", jeb->offset); JFFS2_DEBUG("no nodes in the eraseblock %#08x\n", jeb->offset);
return; return;
} }
printk(KERN_DEBUG); printk(JFFS2_DBG_LVL);
for (ref = jeb->first_node; ; ref = ref->next_phys) { for (ref = jeb->first_node; ; ref = ref->next_phys) {
printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); printk("%#08x(%#x)", ref_offset(ref), ref->__totlen);
if (ref->next_phys) if (ref->next_phys)
...@@ -205,46 +239,83 @@ jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) ...@@ -205,46 +239,83 @@ jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
break; break;
if (++i == 4) { if (++i == 4) {
i = 0; i = 0;
printk("\n" KERN_DEBUG); printk("\n" JFFS2_DBG_LVL);
} }
} }
printk("\n"); printk("\n");
} }
/*
* Dump an eraseblock's space accounting.
*/
void
__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_dump_jeb_nolock(jeb);
spin_unlock(&c->erase_completion_lock);
}
void void
jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb)
{ {
printk(KERN_DEBUG "flash_size: %#08x\n", c->flash_size); if (!jeb)
printk(KERN_DEBUG "used_size: %#08x\n", c->used_size); return;
printk(KERN_DEBUG "dirty_size: %#08x\n", c->dirty_size);
printk(KERN_DEBUG "wasted_size: %#08x\n", c->wasted_size); JFFS2_DEBUG("dump space accounting for the eraseblock at %#08x:\n",
printk(KERN_DEBUG "unchecked_size: %#08x\n", c->unchecked_size); jeb->offset);
printk(KERN_DEBUG "free_size: %#08x\n", c->free_size);
printk(KERN_DEBUG "erasing_size: %#08x\n", c->erasing_size); printk(JFFS2_DBG_LVL "used_size: %#08x\n", jeb->used_size);
printk(KERN_DEBUG "bad_size: %#08x\n", c->bad_size); printk(JFFS2_DBG_LVL "dirty_size: %#08x\n", jeb->dirty_size);
printk(KERN_DEBUG "sector_size: %#08x\n", c->sector_size); printk(JFFS2_DBG_LVL "wasted_size: %#08x\n", jeb->wasted_size);
printk(KERN_DEBUG "jffs2_reserved_blocks size: %#08x\n", printk(JFFS2_DBG_LVL "unchecked_size: %#08x\n", jeb->unchecked_size);
printk(JFFS2_DBG_LVL "free_size: %#08x\n", jeb->free_size);
}
void
__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_dump_block_lists_nolock(c);
spin_unlock(&c->erase_completion_lock);
}
void
__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c)
{
JFFS2_DEBUG("dump JFFS2 blocks lists:\n");
printk(JFFS2_DBG_LVL "flash_size: %#08x\n", c->flash_size);
printk(JFFS2_DBG_LVL "used_size: %#08x\n", c->used_size);
printk(JFFS2_DBG_LVL "dirty_size: %#08x\n", c->dirty_size);
printk(JFFS2_DBG_LVL "wasted_size: %#08x\n", c->wasted_size);
printk(JFFS2_DBG_LVL "unchecked_size: %#08x\n", c->unchecked_size);
printk(JFFS2_DBG_LVL "free_size: %#08x\n", c->free_size);
printk(JFFS2_DBG_LVL "erasing_size: %#08x\n", c->erasing_size);
printk(JFFS2_DBG_LVL "bad_size: %#08x\n", c->bad_size);
printk(JFFS2_DBG_LVL "sector_size: %#08x\n", c->sector_size);
printk(JFFS2_DBG_LVL "jffs2_reserved_blocks size: %#08x\n",
c->sector_size * c->resv_blocks_write); c->sector_size * c->resv_blocks_write);
if (c->nextblock) if (c->nextblock)
printk(KERN_DEBUG "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
c->nextblock->offset, c->nextblock->used_size, c->nextblock->offset, c->nextblock->used_size,
c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->dirty_size, c->nextblock->wasted_size,
c->nextblock->unchecked_size, c->nextblock->free_size); c->nextblock->unchecked_size, c->nextblock->free_size);
else else
printk(KERN_DEBUG "nextblock: NULL\n"); printk(JFFS2_DBG_LVL "nextblock: NULL\n");
if (c->gcblock) if (c->gcblock)
printk(KERN_DEBUG "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size, c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size,
c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size); c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size);
else else
printk(KERN_DEBUG "gcblock: NULL\n"); printk(JFFS2_DBG_LVL "gcblock: NULL\n");
if (list_empty(&c->clean_list)) { if (list_empty(&c->clean_list)) {
printk(KERN_DEBUG "clean_list: empty\n"); printk(JFFS2_DBG_LVL "clean_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
int numblocks = 0; int numblocks = 0;
...@@ -255,19 +326,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -255,19 +326,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
numblocks ++; numblocks ++;
dirty += jeb->wasted_size; dirty += jeb->wasted_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
printk (KERN_DEBUG "Contains %d blocks with total wasted size %u, average wasted size: %u\n", printk (JFFS2_DBG_LVL "Contains %d blocks with total wasted size %u, average wasted size: %u\n",
numblocks, dirty, dirty / numblocks); numblocks, dirty, dirty / numblocks);
} }
if (list_empty(&c->very_dirty_list)) { if (list_empty(&c->very_dirty_list)) {
printk(KERN_DEBUG "very_dirty_list: empty\n"); printk(JFFS2_DBG_LVL "very_dirty_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
int numblocks = 0; int numblocks = 0;
...@@ -279,19 +350,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -279,19 +350,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
numblocks ++; numblocks ++;
dirty += jeb->dirty_size; dirty += jeb->dirty_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", printk (JFFS2_DBG_LVL "Contains %d blocks with total dirty size %u, average dirty size: %u\n",
numblocks, dirty, dirty / numblocks); numblocks, dirty, dirty / numblocks);
} }
if (list_empty(&c->dirty_list)) { if (list_empty(&c->dirty_list)) {
printk(KERN_DEBUG "dirty_list: empty\n"); printk(JFFS2_DBG_LVL "dirty_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
int numblocks = 0; int numblocks = 0;
...@@ -303,19 +374,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -303,19 +374,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
numblocks ++; numblocks ++;
dirty += jeb->dirty_size; dirty += jeb->dirty_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", printk (JFFS2_DBG_LVL "contains %d blocks with total dirty size %u, average dirty size: %u\n",
numblocks, dirty, dirty / numblocks); numblocks, dirty, dirty / numblocks);
} }
if (list_empty(&c->erasable_list)) { if (list_empty(&c->erasable_list)) {
printk(KERN_DEBUG "erasable_list: empty\n"); printk(JFFS2_DBG_LVL "erasable_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -323,16 +394,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -323,16 +394,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->erasing_list)) { if (list_empty(&c->erasing_list)) {
printk(KERN_DEBUG "erasing_list: empty\n"); printk(JFFS2_DBG_LVL "erasing_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -340,16 +411,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -340,16 +411,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->erase_pending_list)) { if (list_empty(&c->erase_pending_list)) {
printk(KERN_DEBUG "erase_pending_list: empty\n"); printk(JFFS2_DBG_LVL "erase_pending_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -357,16 +428,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -357,16 +428,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->erasable_pending_wbuf_list)) { if (list_empty(&c->erasable_pending_wbuf_list)) {
printk(KERN_DEBUG "erasable_pending_wbuf_list: empty\n"); printk(JFFS2_DBG_LVL "erasable_pending_wbuf_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -374,16 +445,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -374,16 +445,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, " printk(JFFS2_DBG_LVL "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, "
"wasted %#08x, unchecked %#08x, free %#08x)\n", "wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->free_list)) { if (list_empty(&c->free_list)) {
printk(KERN_DEBUG "free_list: empty\n"); printk(JFFS2_DBG_LVL "free_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -391,16 +462,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -391,16 +462,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->bad_list)) { if (list_empty(&c->bad_list)) {
printk(KERN_DEBUG "bad_list: empty\n"); printk(JFFS2_DBG_LVL "bad_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -408,16 +479,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -408,16 +479,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
if (list_empty(&c->bad_used_list)) { if (list_empty(&c->bad_used_list)) {
printk(KERN_DEBUG "bad_used_list: empty\n"); printk(JFFS2_DBG_LVL "bad_used_list: empty\n");
} else { } else {
struct list_head *this; struct list_head *this;
...@@ -425,34 +496,42 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) ...@@ -425,34 +496,42 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(KERN_DEBUG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " printk(JFFS2_DBG_LVL "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, "
"unchecked %#08x, free %#08x)\n", "unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
jeb->unchecked_size, jeb->free_size); jeb->unchecked_size, jeb->free_size);
} }
} }
} }
} }
void void
jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f)
{
down(&f->sem);
jffs2_dbg_dump_fragtree_nolock(f);
up(&f->sem);
}
void
__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f)
{ {
struct jffs2_node_frag *this = frag_first(&f->fragtree); struct jffs2_node_frag *this = frag_first(&f->fragtree);
uint32_t lastofs = 0; uint32_t lastofs = 0;
int buggy = 0; int buggy = 0;
printk(KERN_DEBUG "inode is ino #%u\n", f->inocache->ino); JFFS2_DEBUG("dump fragtree of ino #%u\n", f->inocache->ino);
while(this) { while(this) {
if (this->node) if (this->node)
printk(KERN_DEBUG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), " printk(JFFS2_DBG_LVL "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), "
"right (%p), parent (%p)\n", "right (%p), parent (%p)\n",
this->ofs, this->ofs+this->size, ref_offset(this->node->raw), this->ofs, this->ofs+this->size, ref_offset(this->node->raw),
ref_flags(this->node->raw), this, frag_left(this), frag_right(this), ref_flags(this->node->raw), this, frag_left(this), frag_right(this),
frag_parent(this)); frag_parent(this));
else else
printk(KERN_DEBUG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n", printk(JFFS2_DBG_LVL "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n",
this->ofs, this->ofs+this->size, this, frag_left(this), this->ofs, this->ofs+this->size, this, frag_left(this),
frag_right(this), frag_parent(this)); frag_right(this), frag_parent(this));
if (this->ofs != lastofs) if (this->ofs != lastofs)
buggy = 1; buggy = 1;
lastofs = this->ofs + this->size; lastofs = this->ofs + this->size;
...@@ -460,36 +539,171 @@ jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) ...@@ -460,36 +539,171 @@ jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f)
} }
if (f->metadata) if (f->metadata)
printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw)); printk(JFFS2_DBG_LVL "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
if (buggy) { if (buggy) {
printk(KERN_ERR "Error! %s(): Frag tree got a hole in it\n", __FUNCTION__); JFFS2_ERROR("frag tree got a hole in it.\n");
BUG(); BUG();
} }
} }
#define JFFS3_BUFDUMP_BYTES_PER_LINE 8 #define JFFS2_BUFDUMP_BYTES_PER_LINE 32
void void
jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs) __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs)
{ {
int i = 0; int skip;
int skip = offs & ~(JFFS3_BUFDUMP_BYTES_PER_LINE - 1); int i;
JFFS2_DEBUG("dump from offset %#08x to offset %#08x (%x bytes).\n",
offs, offs + len, len);
i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE;
offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);
if (skip != 0)
printk(JFFS2_DBG_LVL "%#08x: ", offs);
while (skip--)
printk(" ");
while (i < len) { while (i < len) {
int j = 0; if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) {
if (i != 0)
printk(KERN_DEBUG "0x#x: \n"); printk("\n");
while (skip) { offs += JFFS2_BUFDUMP_BYTES_PER_LINE;
printk(" "); printk(JFFS2_DBG_LVL "%0#8x: ", offs);
skip -= 1;
} }
while (j < JFFS3_BUFDUMP_BYTES_PER_LINE) { printk("%02x ", buf[i]);
if (i + j < len)
printk(" %#02x", buf[i + j++]); i += 1;
}
printk("\n");
}
/*
* Dump a JFFS2 node.
*/
void
__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs)
{
union jffs2_node_union node;
int len = sizeof(union jffs2_node_union);
size_t retlen;
uint32_t crc;
int ret;
JFFS2_DEBUG("dump node at offset %#08x.\n", ofs);
ret = jffs2_flash_read(c, ofs, len, &retlen, (unsigned char *)&node);
if (ret || (retlen != len)) {
JFFS2_ERROR("read %d bytes failed or short. ret %d, retlen %zd.\n",
len, ret, retlen);
return;
}
printk(JFFS2_DBG_LVL "magic:\t%#04x\n",
je16_to_cpu(node.u.magic));
printk(JFFS2_DBG_LVL "nodetype:\t%#04x\n",
je16_to_cpu(node.u.nodetype));
printk(JFFS2_DBG_LVL "totlen:\t%#08x\n",
je32_to_cpu(node.u.totlen));
printk(JFFS2_DBG_LVL "hdr_crc:\t%#08x\n",
je32_to_cpu(node.u.hdr_crc));
crc = crc32(0, &node.u, sizeof(node.u) - 4);
if (crc != je32_to_cpu(node.u.hdr_crc)) {
JFFS2_ERROR("wrong common header CRC.\n");
return;
}
if (je16_to_cpu(node.u.magic) != JFFS2_MAGIC_BITMASK &&
je16_to_cpu(node.u.magic) != JFFS2_OLD_MAGIC_BITMASK)
{
JFFS2_ERROR("wrong node magic: %#04x instead of %#04x.\n",
je16_to_cpu(node.u.magic), JFFS2_MAGIC_BITMASK);
return;
}
switch(je16_to_cpu(node.u.nodetype)) {
case JFFS2_NODETYPE_INODE:
printk(JFFS2_DBG_LVL "the node is inode node\n");
printk(JFFS2_DBG_LVL "ino:\t%#08x\n",
je32_to_cpu(node.i.ino));
printk(JFFS2_DBG_LVL "version:\t%#08x\n",
je32_to_cpu(node.i.version));
printk(JFFS2_DBG_LVL "mode:\t%#08x\n",
node.i.mode.m);
printk(JFFS2_DBG_LVL "uid:\t%#04x\n",
je16_to_cpu(node.i.uid));
printk(JFFS2_DBG_LVL "gid:\t%#04x\n",
je16_to_cpu(node.i.gid));
printk(JFFS2_DBG_LVL "isize:\t%#08x\n",
je32_to_cpu(node.i.isize));
printk(JFFS2_DBG_LVL "atime:\t%#08x\n",
je32_to_cpu(node.i.atime));
printk(JFFS2_DBG_LVL "mtime:\t%#08x\n",
je32_to_cpu(node.i.mtime));
printk(JFFS2_DBG_LVL "ctime:\t%#08x\n",
je32_to_cpu(node.i.ctime));
printk(JFFS2_DBG_LVL "offset:\t%#08x\n",
je32_to_cpu(node.i.offset));
printk(JFFS2_DBG_LVL "csize:\t%#08x\n",
je32_to_cpu(node.i.csize));
printk(JFFS2_DBG_LVL "dsize:\t%#08x\n",
je32_to_cpu(node.i.dsize));
printk(JFFS2_DBG_LVL "compr:\t%#02x\n",
node.i.compr);
printk(JFFS2_DBG_LVL "usercompr:\t%#02x\n",
node.i.usercompr);
printk(JFFS2_DBG_LVL "flags:\t%#04x\n",
je16_to_cpu(node.i.flags));
printk(JFFS2_DBG_LVL "data_crc:\t%#08x\n",
je32_to_cpu(node.i.data_crc));
printk(JFFS2_DBG_LVL "node_crc:\t%#08x\n",
je32_to_cpu(node.i.node_crc));
crc = crc32(0, &node.i, sizeof(node.i) - 8);
if (crc != je32_to_cpu(node.i.node_crc)) {
JFFS2_ERROR("wrong node header CRC.\n");
return;
}
break;
case JFFS2_NODETYPE_DIRENT:
printk(JFFS2_DBG_LVL "the node is dirent node\n");
printk(JFFS2_DBG_LVL "pino:\t%#08x\n",
je32_to_cpu(node.d.pino));
printk(JFFS2_DBG_LVL "version:\t%#08x\n",
je32_to_cpu(node.d.version));
printk(JFFS2_DBG_LVL "ino:\t%#08x\n",
je32_to_cpu(node.d.ino));
printk(JFFS2_DBG_LVL "mctime:\t%#08x\n",
je32_to_cpu(node.d.mctime));
printk(JFFS2_DBG_LVL "nsize:\t%#02x\n",
node.d.nsize);
printk(JFFS2_DBG_LVL "type:\t%#02x\n",
node.d.type);
printk(JFFS2_DBG_LVL "node_crc:\t%#08x\n",
je32_to_cpu(node.d.node_crc));
printk(JFFS2_DBG_LVL "name_crc:\t%#08x\n",
je32_to_cpu(node.d.name_crc));
node.d.name[node.d.nsize] = '\0';
printk(JFFS2_DBG_LVL "name:\t\"%s\"\n", node.d.name);
crc = crc32(0, &node.d, sizeof(node.d) - 8);
if (crc != je32_to_cpu(node.d.node_crc)) {
JFFS2_ERROR("wrong node header CRC.\n");
return;
} }
break;
i += JFFS3_BUFDUMP_BYTES_PER_LINE; default:
printk(JFFS2_DBG_LVL "node type is unknown\n");
break;
} }
} }
#endif /* JFFS2_PARANOIA_CHECKS || CONFIG_JFFS2_FS_DEBUG > 0 */ #endif /* JFFS2_DBG_DUMPS || JFFS2_DBG_PARANOIA_CHECKS */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: debug.h,v 1.1 2005/07/17 06:56:20 dedekind Exp $ * $Id: debug.h,v 1.5 2005/07/24 15:14:14 dedekind Exp $
* *
*/ */
#ifndef _JFFS2_DEBUG_H_ #ifndef _JFFS2_DEBUG_H_
...@@ -15,12 +15,52 @@ ...@@ -15,12 +15,52 @@
#include <linux/config.h> #include <linux/config.h>
/* ------------------------------------------------ */
/* TODO: remove */
#undef CONFIG_JFFS2_FS_DEBUG
#define CONFIG_JFFS2_FS_DEBUG 0
//#define JFFS2_DBG_PARANOIA_CHECKS
//#define JFFS2_DBG_DUMPS
#define JFFS2_DBG_READINODE_MESSAGES
//#define JFFS2_DBG_FRAGTREE_MESSAGES
//#define JFFS2_DBG_FRAGTREE2_MESSAGES
#undef KERN_DEBUG
#undef KERN_WARNING
#undef KERN_NOTICE
#undef KERN_ERR
#define KERN_DEBUG KERN_CRIT
#define KERN_WARNING KERN_CRIT
#define KERN_NOTICE KERN_CRIT
#define KERN_ERR KERN_CRIT
/* ------------------------------------------------ */
#ifndef CONFIG_JFFS2_FS_DEBUG #ifndef CONFIG_JFFS2_FS_DEBUG
#define CONFIG_JFFS2_FS_DEBUG 1 #define CONFIG_JFFS2_FS_DEBUG 1
#endif #endif
#if CONFIG_JFFS2_FS_DEBUG > 0 #if CONFIG_JFFS2_FS_DEBUG == 1
/* Enable "paranoia" checks and dumps */
#define JFFS2_DBG_PARANOIA_CHECKS #define JFFS2_DBG_PARANOIA_CHECKS
#define JFFS2_DBG_DUMPS
#define JFFS2_DBG_READINODE_MESSAGES
#define JFFS2_DBG_FRAGTREE_MESSAGES
#define JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_INOCACHE_MESSAGES
#endif
#if CONFIG_JFFS2_FS_DEBUG == 2
#define JFFS2_DBG_FRAGTREE2_MESSAGES
#endif
/* Enable JFFS2 sanity checks by default */
#define JFFS2_DBG_SANITY_CHECKS
/*
* Dx() are mainly used for debugging messages, they must go away and be
* superseded by nicer JFFS2_DBG_XXX() macros...
*/
#if CONFIG_JFFS2_FS_DEBUG > 0
#define D1(x) x #define D1(x) x
#else #else
#define D1(x) #define D1(x)
...@@ -32,73 +72,216 @@ ...@@ -32,73 +72,216 @@
#define D2(x) #define D2(x)
#endif #endif
/* Enable JFFS2 sanity checks */ /* The prefixes of JFFS2 messages */
#define JFFS2_DBG_SANITY_CHECKS #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]"
#define JFFS2_ERR_MSG_PREFIX "JFFS2 error: "
#define JFFS2_WARN_MSG_PREFIX "JFFS2 warning: "
#define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice: "
#if CONFIG_JFFS2_FS_DEBUG > 0 #define JFFS2_ERR_LVL KERN_ERR
void #define JFFS2_WARN_LVL KERN_WARNING
jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); #define JFFS2_NOTICE_LVL KERN_NOTICE
#define JFFS2_DBG_LVL KERN_DEBUG
void /* JFFS2 message macros */
jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); #define JFFS2_ERROR(fmt, ...) \
do { \
printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX " %s: " \
fmt, __FUNCTION__, ##__VA_ARGS__); \
} while(0)
void #define JFFS2_WARNING(fmt, ...) \
jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); do { \
printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX " %s: " \
fmt, __FUNCTION__, ##__VA_ARGS__); \
} while(0)
#define JFFS2_NOTICE(fmt, ...) \
do { \
printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX " %s: " \
fmt, __FUNCTION__, ##__VA_ARGS__); \
} while(0)
void #define JFFS2_DEBUG(fmt, ...) \
jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs); do { \
printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX " %s: " \
fmt, __FUNCTION__, ##__VA_ARGS__); \
} while(0)
/*
* We split our debugging messages on several parts, depending on the JFFS2
* subsystem the message belongs to.
*/
/* Read inode debugging messages */
#ifdef JFFS2_DBG_READINODE_MESSAGES
#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_READINODE(fmt, ...)
#endif #endif
#ifdef JFFS2_DBG_PARANOIA_CHECKS /* Fragtree build debugging messages */
void #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); #define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_FRAGTREE(fmt, ...)
#endif
/* Directory entry list manilulation debugging messages */
#ifdef JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_DENTLIST(fmt, ...)
#endif
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_FRAGTREE2(fmt, ...)
#endif
/* Plays with node_refs */
#ifdef JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_NODEREF(fmt, ...)
#endif
/* Plays with the list of inodes (JFFS2 inocache) */
#ifdef JFFS2_DBG_INOCACHE_MESSAGES
#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_INOCACHE(fmt, ...)
#endif
/* "Paranoia" checks */
void
__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
void void
jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
struct jffs2_eraseblock *jeb); void
__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
uint32_t ofs, int len);
/* "Dump" functions */
void
__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
void
__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
void
__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
void
__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
void void
jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
uint32_t ofs, int len); void
__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
#ifdef JFFS2_DBG_PARANOIA_CHECKS
#define jffs2_dbg_fragtree_paranoia_check(f) \
__jffs2_dbg_fragtree_paranoia_check(f)
#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
__jffs2_dbg_fragtree_paranoia_check_nolock(f)
#define jffs2_dbg_acct_paranoia_check(c, jeb) \
__jffs2_dbg_acct_paranoia_check(c,jeb)
#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
__jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
__jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
#else #else
#define jffs2_dbg_fragtree_paranoia_check(f) #define jffs2_dbg_fragtree_paranoia_check(f)
#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
#define jffs2_dbg_acct_paranoia_check(c, jeb) #define jffs2_dbg_acct_paranoia_check(c, jeb)
#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
#endif /* !JFFS2_PARANOIA_CHECKS */ #endif /* !JFFS2_PARANOIA_CHECKS */
#ifdef JFFS2_DBG_DUMPS
#define jffs2_dbg_dump_jeb(c, jeb) \
__jffs2_dbg_dump_jeb(c, jeb);
#define jffs2_dbg_dump_jeb_nolock(jeb) \
__jffs2_dbg_dump_jeb_nolock(jeb);
#define jffs2_dbg_dump_block_lists(c) \
__jffs2_dbg_dump_block_lists(c)
#define jffs2_dbg_dump_block_lists_nolock(c) \
__jffs2_dbg_dump_block_lists_nolock(c)
#define jffs2_dbg_dump_fragtree(f) \
__jffs2_dbg_dump_fragtree(f);
#define jffs2_dbg_dump_fragtree_nolock(f) \
__jffs2_dbg_dump_fragtree_nolock(f);
#define jffs2_dbg_dump_buffer(buf, len, offs) \
__jffs2_dbg_dump_buffer(*buf, len, offs);
#define jffs2_dbg_dump_node(c, ofs) \
__jffs2_dbg_dump_node(c, ofs);
#else
#define jffs2_dbg_dump_jeb(c, jeb)
#define jffs2_dbg_dump_jeb_nolock(jeb)
#define jffs2_dbg_dump_block_lists(c)
#define jffs2_dbg_dump_block_lists_nolock(c)
#define jffs2_dbg_dump_fragtree(f)
#define jffs2_dbg_dump_fragtree_nolock(f)
#define jffs2_dbg_dump_buffer(buf, len, offs)
#define jffs2_dbg_dump_node(c, ofs)
#endif /* !JFFS2_DBG_DUMPS */
/*
* Sanity checks are supposed to be light-weight and enabled by default.
*/
#ifdef JFFS2_DBG_SANITY_CHECKS #ifdef JFFS2_DBG_SANITY_CHECKS
/* /*
* Check the space accounting of the file system and of * Check the space accounting of the file system and of
* the JFFS3 erasable block 'jeb'. * the JFFS2 erasable block 'jeb'.
*/ */
static inline void static inline void
jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb) struct jffs2_eraseblock *jeb)
{ {
if (unlikely(jeb && jeb->used_size + jeb->dirty_size + if (unlikely(jeb && jeb->used_size + jeb->dirty_size +
jeb->free_size + jeb->wasted_size + jeb->free_size + jeb->wasted_size +
jeb->unchecked_size != c->sector_size)) { jeb->unchecked_size != c->sector_size)) {
printk(KERN_ERR "Eeep. Space accounting for block at 0x%08x is screwed\n", jeb->offset); JFFS2_ERROR("eeep, space accounting for block at 0x%08x is screwed.\n", jeb->offset);
printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked " JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked "
"%#08x != total %#08x\n", jeb->free_size, jeb->dirty_size, jeb->used_size, "%#08x != total %#08x.\n", jeb->free_size, jeb->dirty_size, jeb->used_size,
jeb->wasted_size, jeb->unchecked_size, c->sector_size); jeb->wasted_size, jeb->unchecked_size, c->sector_size);
BUG(); BUG();
} }
if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size
+ c->wasted_size + c->unchecked_size != c->flash_size)) { + c->wasted_size + c->unchecked_size != c->flash_size)) {
printk(KERN_ERR "Eeep. Space accounting superblock info is screwed\n"); JFFS2_ERROR("eeep, space accounting superblock info is screwed.\n");
printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + " JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + "
"wasted %#08x + unchecked %#08x != total %#08x\n", "wasted %#08x + unchecked %#08x != total %#08x.\n",
c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size,
c->wasted_size, c->unchecked_size, c->flash_size); c->wasted_size, c->unchecked_size, c->flash_size);
BUG(); BUG();
} }
} }
#else
static inline void static inline void
jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb); struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
jffs2_dbg_acct_sanity_check_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock);
}
#else
#define jffs2_dbg_acct_sanity_check(c, jeb)
#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
#endif /* !JFFS2_DBG_SANITY_CHECKS */ #endif /* !JFFS2_DBG_SANITY_CHECKS */
#endif /* _JFFS2_DEBUG_H_ */ #endif /* _JFFS2_DEBUG_H_ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: erase.c,v 1.81 2005/07/17 06:56:20 dedekind Exp $ * $Id: erase.c,v 1.83 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -48,7 +48,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, ...@@ -48,7 +48,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
#else /* Linux */ #else /* Linux */
struct erase_info *instr; struct erase_info *instr;
D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#x (range %#x-%#x)\n", jeb->offset, jeb->offset, jeb->offset + c->sector_size)); D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n",
jeb->offset, jeb->offset, jeb->offset + c->sector_size));
instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL);
if (!instr) { if (!instr) {
printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
...@@ -429,8 +430,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb ...@@ -429,8 +430,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
c->free_size += jeb->free_size; c->free_size += jeb->free_size;
c->used_size += jeb->used_size; c->used_size += jeb->used_size;
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check_nolock(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
list_add_tail(&jeb->list, &c->free_list); list_add_tail(&jeb->list, &c->free_list);
c->nr_erasing_blocks--; c->nr_erasing_blocks--;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: fs.c,v 1.59 2005/07/18 11:21:19 dedekind Exp $ * $Id: fs.c,v 1.60 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -194,19 +194,15 @@ int jffs2_statfs(struct super_block *sb, struct kstatfs *buf) ...@@ -194,19 +194,15 @@ int jffs2_statfs(struct super_block *sb, struct kstatfs *buf)
buf->f_namelen = JFFS2_MAX_NAME_LEN; buf->f_namelen = JFFS2_MAX_NAME_LEN;
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
avail = c->dirty_size + c->free_size; avail = c->dirty_size + c->free_size;
if (avail > c->sector_size * c->resv_blocks_write) if (avail > c->sector_size * c->resv_blocks_write)
avail -= c->sector_size * c->resv_blocks_write; avail -= c->sector_size * c->resv_blocks_write;
else else
avail = 0; avail = 0;
spin_unlock(&c->erase_completion_lock);
buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT; buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
jffs2_dbg_dump_block_lists(c);
spin_unlock(&c->erase_completion_lock);
return 0; return 0;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: gc.c,v 1.150 2005/07/17 12:01:43 dedekind Exp $ * $Id: gc.c,v 1.152 2005/07/24 15:14:14 dedekind Exp $
* *
*/ */
...@@ -111,7 +111,6 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) ...@@ -111,7 +111,6 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c)
ret->wasted_size = 0; ret->wasted_size = 0;
} }
jffs2_dbg_dump_block_lists(c);
return ret; return ret;
} }
...@@ -142,7 +141,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -142,7 +141,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
if (c->checked_ino > c->highest_ino) { if (c->checked_ino > c->highest_ino) {
printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n",
c->unchecked_size); c->unchecked_size);
jffs2_dbg_dump_block_lists(c); jffs2_dbg_dump_block_lists_nolock(c);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
BUG(); BUG();
} }
...@@ -485,7 +484,8 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era ...@@ -485,7 +484,8 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era
if (ref_obsolete(raw)) { if (ref_obsolete(raw)) {
printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); printk(KERN_WARNING "But it's obsolete so we don't mind too much\n");
} else { } else {
ret = -EIO; jffs2_dbg_dump_node(c, ref_offset(raw));
BUG();
} }
} }
upnout: upnout:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: nodelist.c,v 1.99 2005/07/15 10:13:54 dedekind Exp $ * $Id: nodelist.c,v 1.100 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -203,7 +203,7 @@ read_direntry(struct jffs2_sb_info *c, ...@@ -203,7 +203,7 @@ read_direntry(struct jffs2_sb_info *c,
return -EIO; return -EIO;
if (unlikely(err)) { if (unlikely(err)) {
printk(KERN_WARNING "Read remainder of name in jffs2_get_inode_nodes(): error %d\n", err); printk(KERN_WARNING "Read remainder of name: error %d\n", err);
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
return -EIO; return -EIO;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: nodelist.h,v 1.132 2005/07/17 06:56:21 dedekind Exp $ * $Id: nodelist.h,v 1.133 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -236,7 +236,7 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, ...@@ -236,7 +236,7 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c,
ret, ref->__totlen); ret, ref->__totlen);
if (!jeb) if (!jeb)
jeb = &c->blocks[ref->flash_offset / c->sector_size]; jeb = &c->blocks[ref->flash_offset / c->sector_size];
jffs2_dbg_dump_node_refs(c, jeb); jffs2_dbg_dump_node_refs_nolock(c, jeb);
BUG(); BUG();
} }
#endif #endif
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: nodemgmt.c,v 1.123 2005/07/17 06:56:21 dedekind Exp $ * $Id: nodemgmt.c,v 1.124 2005/07/20 15:32:28 dedekind Exp $
* *
*/ */
...@@ -349,8 +349,8 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r ...@@ -349,8 +349,8 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
list_add_tail(&jeb->list, &c->clean_list); list_add_tail(&jeb->list, &c->clean_list);
c->nextblock = NULL; c->nextblock = NULL;
} }
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check_nolock(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -430,7 +430,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -430,7 +430,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size); ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size);
BUG(); BUG();
}) })
D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref))); D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), ref_totlen(c, jeb, ref)));
jeb->used_size -= ref_totlen(c, jeb, ref); jeb->used_size -= ref_totlen(c, jeb, ref);
c->used_size -= ref_totlen(c, jeb, ref); c->used_size -= ref_totlen(c, jeb, ref);
} }
...@@ -466,9 +466,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -466,9 +466,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
} }
ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; ref->flash_offset = ref_offset(ref) | REF_OBSOLETE;
jffs2_dbg_acct_sanity_check(c, jeb); jffs2_dbg_acct_sanity_check_nolock(c, jeb);
jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
jffs2_dbg_acct_paranoia_check(c, jeb);
if (c->flags & JFFS2_SB_FLAG_SCANNING) { if (c->flags & JFFS2_SB_FLAG_SCANNING) {
/* Flash scanning is in progress. Don't muck about with the block /* Flash scanning is in progress. Don't muck about with the block
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: read.c,v 1.40 2005/07/17 06:56:21 dedekind Exp $ * $Id: read.c,v 1.41 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -174,7 +174,6 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -174,7 +174,6 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
if (frag) { if (frag) {
D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset)); D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset));
holesize = min(holesize, frag->ofs - offset); holesize = min(holesize, frag->ofs - offset);
D2(jffs2_dbg_dump_fragtree(f));
} }
D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize));
memset(buf, 0, holesize); memset(buf, 0, holesize);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: readinode.c,v 1.128 2005/07/17 12:01:43 dedekind Exp $ * $Id: readinode.c,v 1.129 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -92,8 +92,8 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in ...@@ -92,8 +92,8 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
mark_ref_normal(next->node->raw); mark_ref_normal(next->node->raw);
} }
} }
jffs2_dbg_fragtree_paranoia_check(f); jffs2_dbg_fragtree_paranoia_check_nolock(f);
jffs2_dbg_dump_fragtree(f); jffs2_dbg_dump_fragtree_nolock(f);
return 0; return 0;
} }
...@@ -480,7 +480,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -480,7 +480,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
jffs2_free_tmp_dnode_info(tn); jffs2_free_tmp_dnode_info(tn);
} }
jffs2_dbg_fragtree_paranoia_check(f); jffs2_dbg_fragtree_paranoia_check_nolock(f);
if (!fn) { if (!fn) {
/* No data nodes for this inode. */ /* No data nodes for this inode. */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: scan.c,v 1.120 2005/07/17 06:56:21 dedekind Exp $ * $Id: scan.c,v 1.121 2005/07/20 15:32:28 dedekind Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -130,7 +130,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -130,7 +130,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
if (ret < 0) if (ret < 0)
goto out; goto out;
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
/* Now decide which list to put it on */ /* Now decide which list to put it on */
switch(ret) { switch(ret) {
...@@ -370,7 +370,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -370,7 +370,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
scan_more: scan_more:
while(ofs < jeb->offset + c->sector_size) { while(ofs < jeb->offset + c->sector_size) {
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
cond_resched(); cond_resched();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: wbuf.c,v 1.94 2005/07/17 12:01:43 dedekind Exp $ * $Id: wbuf.c,v 1.96 2005/07/22 10:32:08 dedekind Exp $
* *
*/ */
...@@ -139,7 +139,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -139,7 +139,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
{ {
D1(printk("About to refile bad block at %08x\n", jeb->offset)); D1(printk("About to refile bad block at %08x\n", jeb->offset));
jffs2_dbg_dump_block_lists(c);
/* File the existing block on the bad_used_list.... */ /* File the existing block on the bad_used_list.... */
if (c->nextblock == jeb) if (c->nextblock == jeb)
c->nextblock = NULL; c->nextblock = NULL;
...@@ -156,7 +155,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -156,7 +155,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_erase_pending_trigger(c); jffs2_erase_pending_trigger(c);
} }
jffs2_dbg_dump_block_lists(c);
/* Adjust its size counts accordingly */ /* Adjust its size counts accordingly */
c->wasted_size += jeb->free_size; c->wasted_size += jeb->free_size;
...@@ -164,8 +162,9 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -164,8 +162,9 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
jeb->wasted_size += jeb->free_size; jeb->wasted_size += jeb->free_size;
jeb->free_size = 0; jeb->free_size = 0;
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_dump_block_lists_nolock(c);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_sanity_check_nolock(c,jeb);
jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
} }
/* Recover from failure to write wbuf. Recover the nodes up to the /* Recover from failure to write wbuf. Recover the nodes up to the
...@@ -392,11 +391,11 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -392,11 +391,11 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
else else
jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys); jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys);
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check_nolock(c, jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
jffs2_dbg_acct_sanity_check(c,new_jeb); jffs2_dbg_acct_sanity_check_nolock(c, new_jeb);
jffs2_dbg_acct_paranoia_check(c, new_jeb); jffs2_dbg_acct_paranoia_check_nolock(c, new_jeb);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: write.c,v 1.93 2005/07/17 06:56:21 dedekind Exp $ * $Id: write.c,v 1.94 2005/07/20 15:50:51 dedekind Exp $
* *
*/ */
...@@ -223,8 +223,6 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -223,8 +223,6 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),
je32_to_cpu(rd->name_crc))); je32_to_cpu(rd->name_crc)));
jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) {
printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n");
BUG(); BUG();
...@@ -236,6 +234,8 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -236,6 +234,8 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
vecs[1].iov_base = (unsigned char *)name; vecs[1].iov_base = (unsigned char *)name;
vecs[1].iov_len = namelen; vecs[1].iov_len = namelen;
jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
raw = jffs2_alloc_raw_node_ref(); raw = jffs2_alloc_raw_node_ref();
if (!raw) if (!raw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment