13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/kernel.h>
16 #include <linux/types.h>
21 #include <linux/slab.h>
25 #ifdef JFFS2_DBG_SANITY_CHECKS
34 JFFS2_ERROR(
"eeep, space accounting for block at 0x%08x is screwed.\n", jeb->
offset);
35 JFFS2_ERROR(
"free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked %#08x != total %#08x.\n",
43 JFFS2_ERROR(
"eeep, space accounting superblock info is screwed.\n");
44 JFFS2_ERROR(
"free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + wasted %#08x + unchecked %#08x != total %#08x.\n",
62 #ifdef JFFS2_DBG_PARANOIA_CHECKS
88 JFFS2_ERROR(
"REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n",
100 JFFS2_ERROR(
"REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2.\n",
107 JFFS2_ERROR(
"REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n",
137 if (ret || (retlen != len)) {
138 JFFS2_WARNING(
"read %d bytes failed or short. ret %d, retlen %zd.\n",
145 for (i = 0; i < len; i++)
150 JFFS2_ERROR(
"argh, about to write node to %#08x on flash, but there are data already there. The first corrupted byte is at %#08x offset.\n",
164 erasing = 0,
bad = 0, unchecked = 0;
173 wasted += c->
gcblock->wasted_size;
174 unchecked += c->
gcblock->unchecked_size;
182 unchecked += c->
nextblock->unchecked_size;
268 if (sz != c->sz##_size) { \
269 pr_warn("%s_size mismatch counted 0x%x, c->%s_size 0x%x\n", \
270 #sz, sz, #sz, c->sz##_size); \
286 pr_warn(
"%s counted only 0x%x blocks of 0x%x. Where are the others?\n",
323 JFFS2_ERROR(
"node_ref %#08x shouldn't be in block at %#08x.\n",
329 my_unchecked_size +=
totlen;
335 if ((!ref_next(ref2)) != (ref2 == jeb->
last_node)) {
336 JFFS2_ERROR(
"node_ref for node at %#08x (mem %p) has next at %#08x (mem %p), last_node is at %#08x (mem %p).\n",
341 ref2 = ref_next(ref2);
345 JFFS2_ERROR(
"Calculated used size %#08x != stored used size %#08x.\n",
351 JFFS2_ERROR(
"Calculated unchecked size %#08x != stored unchecked size %#08x.\n",
359 JFFS2_ERROR(
"Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n",
365 && my_used_size + my_unchecked_size + my_dirty_size != c->
sector_size) {
366 JFFS2_ERROR(
"The sum of all nodes in block (%#x) != size of block (%#x)\n",
367 my_used_size + my_unchecked_size + my_dirty_size,
374 __jffs2_dbg_superblock_counts(c);
387 #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS)
414 for (ref = jeb->
first_node; ; ref = ref_next(ref)) {
417 printk(
"(%x)", ref->__totlen);
484 printk(
JFFS2_DBG "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
492 printk(
JFFS2_DBG "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
510 printk(
JFFS2_DBG "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
516 printk (
JFFS2_DBG "Contains %d blocks with total wasted size %u, average wasted size: %u\n",
517 numblocks, dirty, dirty / numblocks);
533 printk(
JFFS2_DBG "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
539 printk (
JFFS2_DBG "Contains %d blocks with total dirty size %u, average dirty size: %u\n",
540 numblocks, dirty, dirty / numblocks);
556 printk(
JFFS2_DBG "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
562 printk (
JFFS2_DBG "contains %d blocks with total dirty size %u, average dirty size: %u\n",
563 numblocks, dirty, dirty / numblocks);
575 printk(
JFFS2_DBG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
591 printk(
JFFS2_DBG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
606 printk(
JFFS2_DBG "erase_checking_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
622 printk(
JFFS2_DBG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
638 printk(
JFFS2_DBG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
654 printk(
JFFS2_DBG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
670 printk(
JFFS2_DBG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
686 printk(
JFFS2_DBG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
712 printk(
JFFS2_DBG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), right (%p), parent (%p)\n",
717 printk(
JFFS2_DBG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n",
720 if (this->ofs != lastofs)
722 lastofs = this->ofs + this->
size;
735 #define JFFS2_BUFDUMP_BYTES_PER_LINE 32
743 offs, offs + len, len);
744 i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE;
745 offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);
754 if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) {
757 offs += JFFS2_BUFDUMP_BYTES_PER_LINE;
784 if (ret || (retlen != len)) {
785 JFFS2_ERROR(
"read %d bytes failed or short. ret %d, retlen %zd.\n",
804 JFFS2_ERROR(
"wrong node magic: %#04x instead of %#04x.\n",