mtd/fs/jffs3 scan.c,3.2,3.3
Artem Bityuckiy
dedekind at infradead.org
Mon Dec 13 14:02:46 EST 2004
Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv25099
Modified Files:
scan.c
Log Message:
Use output macros instead of printk to make output more uniform.
Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/scan.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- scan.c 13 Dec 2004 15:37:37 -0000 3.2
+++ scan.c 13 Dec 2004 19:02:43 -0000 3.3
@@ -7,7 +7,7 @@
*
* For licensing information, see the file 'LICENCE' in this directory.
*
- * JFFS2 Id: scan.c,v 1.115 2004/11/17 12:59:08 dedekind Exp
+ * JFFS3 Id: scan.c,v 1.115 2004/11/17 12:59:08 dedekind Exp
* $Id$
*
*/
@@ -35,13 +35,13 @@
jeb->free_size -= _x ; jeb->unchecked_size += _x; \
}while(0)
-#define noisy_printk(noise, args...) do { \
+#define DBG_NOISY(noise, args...) do { \
if (*(noise)) { \
- printk(KERN_NOTICE args); \
- (*(noise))--; \
- if (!(*(noise))) { \
- printk(KERN_NOTICE "Further such events for this erase block will not be printed\n"); \
- } \
+ NOTICE_MSG(args); \
+ NOTICE_MSG("This may happen if JFFS3 was not cleanly unmounted\n"); \
+ (*(noise))--; \
+ if (!(*(noise))) \
+ NOTICE_MSG("Further such events for this erase block will not be printed\n"); \
} \
} while(0)
@@ -89,12 +89,12 @@
ret = c->mtd->point (c->mtd, 0, c->mtd->size, &pointlen, &flashbuf);
if (!ret && pointlen < c->mtd->size) {
/* Don't muck about if it won't let us point to the whole flash */
- D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen));
+ DBG_SCAN(1, "MTD point returned len too short: %#zx\n", pointlen);
c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size);
flashbuf = NULL;
}
if (ret)
- D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
+ DBG_SCAN(1, "MTD point failed with return code %d\n", ret);
}
#endif
if (!flashbuf) {
@@ -109,7 +109,7 @@
if (buf_size > 128*1024)
buf_size = 128*1024;
- D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size));
+ DBG_SCAN(1, "Allocating readbuf of %d bytes\n", buf_size);
flashbuf = kmalloc(buf_size, GFP_KERNEL);
if (!flashbuf)
return -ENOMEM;
@@ -148,7 +148,8 @@
c->nr_free_blocks++;
} else {
/* Dirt */
- D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset));
+ DBG_SCAN(1, "Adding all-dirty block at %#08x to "
+ "erase_pending_list\n", jeb->offset);
list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
}
@@ -196,20 +197,21 @@
case BLK_STATE_ALLDIRTY:
/* Nothing valid - not even a clean marker. Needs erasing. */
/* For now we just put it on the erasing list. We'll start the erases later */
- D1(printk(KERN_NOTICE "JFFS3: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset));
- list_add(&jeb->list, &c->erase_pending_list);
+ DBG_SCAN(1, "Erase block at %#08x is not formatted. It will "
+ "be erased\n", jeb->offset);
+ list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
break;
case BLK_STATE_BADBLOCK:
- D1(printk(KERN_NOTICE "JFFS3: Block at 0x%08x is bad\n", jeb->offset));
- list_add(&jeb->list, &c->bad_list);
+ DBG_SCAN(1, "Block at %#08x is bad\n", jeb->offset);
+ list_add(&jeb->list, &c->bad_list);
c->bad_size += c->sector_size;
c->free_size -= c->sector_size;
bad_blocks++;
break;
default:
- printk(KERN_WARNING "jffs3_scan_medium(): unknown block state\n");
+ ERROR_MSG("Unknown block state\n");
BUG();
}
}
@@ -229,8 +231,7 @@
uint32_t skip = c->nextblock->free_size & (c->wbuf_pagesize-1);
- D1(printk(KERN_DEBUG "jffs3_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n",
- skip));
+ DBG_SCAN(1, "Skipping %d bytes in nextblock to ensure page alignment\n", skip);
c->nextblock->wasted_size += skip;
c->wasted_size += skip;
@@ -239,9 +240,12 @@
}
#endif
if (c->nr_erasing_blocks) {
- if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
- printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS3 nodes\n");
- printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks);
+ if ( !c->used_size && ((c->nr_free_blocks + empty_blocks+bad_blocks)
+ != c->nr_blocks || bad_blocks == c->nr_blocks) ) {
+ NOTICE_MSG("Cowardly refusing to erase blocks on filesystem with "
+ "no valid JFFS3 nodes\n");
+ NOTICE_MSG("Empty blocks %d, bad blocks %d, total blocks %d\n",
+ empty_blocks,bad_blocks,c->nr_blocks);
ret = -EIO;
goto out;
}
@@ -266,16 +270,19 @@
ret = jffs3_flash_read(c, ofs, len, &retlen, buf);
if (ret) {
- D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret));
+ WARNING_MSG("mtd->read(%#08x bytes from %#08x) returned %d\n", len, ofs, ret);
return ret;
}
if (retlen < len) {
- D1(printk(KERN_WARNING "Read at 0x%x gave only 0x%zx bytes\n", ofs, retlen));
+ WARNING_MSG("Read at %#08x gave only 0x%zx bytes\n", ofs, retlen);
return -EIO;
}
- D2(printk(KERN_DEBUG "Read 0x%x bytes from 0x%08x into buf\n", len, ofs));
- D2(printk(KERN_DEBUG "000: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]));
+
+ DBG_SCAN(2, "Read %#08x bytes from %#08x into buf\n", len, ofs);
+ DBG_SCAN(2, "000: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x "
+ "%02x %02x %02x %02x %02x %02x\n", buf[0], buf[1],
+ buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
+ buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
return 0;
}
@@ -294,12 +301,12 @@
ofs = jeb->offset;
prevofs = jeb->offset - 1;
- D1(printk(KERN_DEBUG "jffs3_scan_eraseblock(): Scanning block at 0x%x\n", ofs));
+ DBG_SCAN(1, "Scanning block at %#x\n", ofs);
#ifdef CONFIG_JFFS3_FS_NAND
if (jffs3_cleanmarker_oob(c)) {
int ret = jffs3_check_nand_cleanmarker(c, jeb);
- D2(printk(KERN_DEBUG "jffs_check_nand_cleanmarker returned %d\n",ret));
+ DBG_SCAN(1, "jffs_check_nand_cleanmarker returned %d\n", ret);
/* Even if it's not found, we still scan to see
if the block is empty. We use this information
to decide whether to erase it or not. */
@@ -335,7 +342,7 @@
if (jffs3_cleanmarker_oob(c)) {
/* scan oob, take care of cleanmarker */
int ret = jffs3_check_oob_empty(c, jeb, cleanmarkerfound);
- D2(printk(KERN_DEBUG "jffs3_check_oob_empty returned %d\n",ret));
+ DBG_SCAN(2, "jffs3_check_oob_empty returned %d\n", ret);
switch (ret) {
case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF;
case 1: return BLK_STATE_ALLDIRTY;
@@ -343,12 +350,12 @@
}
}
#endif
- D1(printk(KERN_DEBUG "Block at 0x%08x is empty (erased)\n", jeb->offset));
+ DBG_SCAN(1, "Block at %#08x is empty (erased\n", jeb->offset);
return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */
}
if (ofs) {
- D1(printk(KERN_DEBUG "Free space at %08x ends at %08x\n", jeb->offset,
- jeb->offset + ofs));
+ DBG_SCAN(2, "Free space at %#08x ends at %#08x\n",
+ jeb->offset, jeb->offset + ofs);
DIRTY_SPACE(ofs);
}
@@ -365,12 +372,12 @@
cond_resched();
if (ofs & 3) {
- printk(KERN_WARNING "Eep. ofs 0x%08x not word-aligned!\n", ofs);
+ WARNING_MSG("Eep. ofs %#08x not word-aligned!\n", ofs);
ofs = PAD(ofs);
continue;
}
if (ofs == prevofs) {
- printk(KERN_WARNING "ofs 0x%08x has already been seen. Skipping\n", ofs);
+ WARNING_MSG("ofs %#08x has already been seen. Skipping\n", ofs);
DIRTY_SPACE(4);
ofs += 4;
continue;
@@ -378,16 +385,19 @@
prevofs = ofs;
if (jeb->offset + c->sector_size < ofs + sizeof(*node)) {
- D1(printk(KERN_DEBUG "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n", sizeof(struct jffs3_unknown_node),
- jeb->offset, c->sector_size, ofs, sizeof(*node)));
+ DBG_SCAN(1, "Fewer than %zd bytes left to end of block. "
+ "(%#08x+%#08x<%#08x+%zx Not reading\n",
+ sizeof(struct jffs3_unknown_node),
+ jeb->offset, c->sector_size, ofs, sizeof(*node));
DIRTY_SPACE((jeb->offset + c->sector_size)-ofs);
break;
}
if (buf_ofs + buf_len < ofs + sizeof(*node)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
- D1(printk(KERN_DEBUG "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n",
- sizeof(struct jffs3_unknown_node), buf_len, ofs));
+ DBG_SCAN(1, "Fewer than %zd bytes (node header left to end "
+ "of buf. Reading %#08x at %#08x\n",
+ sizeof(struct jffs3_unknown_node), buf_len, ofs);
err = jffs3_fill_scan_buf(c, buf, ofs, buf_len);
if (err)
return err;
@@ -403,13 +413,13 @@
empty_start = ofs;
ofs += 4;
- D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs));
+ DBG_SCAN(1, "Found empty flash at %#08x\n", ofs);
more_empty:
inbuf_ofs = ofs - buf_ofs;
while (inbuf_ofs < buf_len) {
if (*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff) {
- printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n",
- empty_start, ofs);
+ WARNING_MSG("Empty flash at %#08x ends at %#08x\n",
+ empty_start, ofs);
DIRTY_SPACE(ofs-empty_start);
goto scan_more;
}
@@ -418,13 +428,14 @@
ofs += 4;
}
/* Ran off end. */
- D1(printk(KERN_DEBUG "Empty flash to end of buffer at 0x%08x\n", ofs));
+ DBG_SCAN(1, "Empty flash to end of buffer at %#08x\n", ofs);
/* If we're only checking the beginning of a block with a cleanmarker,
bail now */
if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) &&
c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_in_ino) {
- D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE));
+ DBG_SCAN(1, "%d bytes at start of block seems clean... "
+ "assuming all clean\n", EMPTY_SCAN_SIZE);
return BLK_STATE_CLEANMARKER;
}
@@ -433,11 +444,11 @@
if (!buf_len) {
/* No more to read. Break out of main loop without marking
this range of empty space as dirty (because it's not) */
- D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n",
- empty_start));
+ DBG_SCAN(1, "Empty flash at %#08x runs to end of "
+ "block. Treating as free_space\n", empty_start);
break;
}
- D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs));
+ DBG_SCAN(1, "Reading another %#08x at %#08x\n", buf_len, ofs);
err = jffs3_fill_scan_buf(c, buf, ofs, buf_len);
if (err)
return err;
@@ -446,27 +457,28 @@
}
if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) {
- printk(KERN_WARNING "Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", ofs);
+ WARNING_MSG("Magic bitmask is backwards at offset %#08x. "
+ "Wrong endian filesystem?\n", ofs);
DIRTY_SPACE(4);
ofs += 4;
continue;
}
if (je16_to_cpu(node->magic) == JFFS3_DIRTY_BITMASK) {
- D1(printk(KERN_DEBUG "Dirty bitmask at 0x%08x\n", ofs));
+ DBG_SCAN(1, "Dirty bitmask at %#08x\n", ofs);
DIRTY_SPACE(4);
ofs += 4;
continue;
}
if (je16_to_cpu(node->magic) == JFFS3_OLD_MAGIC_BITMASK) {
- printk(KERN_WARNING "Old JFFS3 bitmask found at 0x%08x\n", ofs);
- printk(KERN_WARNING "You cannot use older JFFS3 filesystems with newer kernels\n");
+ WARNING_MSG("Old JFFS3 bitmask found at %#08x\n", ofs);
+ WARNING_MSG("You cannot use older JFFS3 filesystems with newer kernels\n");
DIRTY_SPACE(4);
ofs += 4;
continue;
}
if (je16_to_cpu(node->magic) != JFFS3_MAGIC_BITMASK) {
/* OK. We're out of possibilities. Whinge and move on */
- noisy_printk(&noise, "jffs3_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n",
+ DBG_NOISY(&noise, "Magic bitmask 0x%04x not found at %#08x: 0x%04x instead\n",
JFFS3_MAGIC_BITMASK, ofs,
je16_to_cpu(node->magic));
DIRTY_SPACE(4);
@@ -480,12 +492,10 @@
hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4);
if (hdr_crc != je32_to_cpu(node->hdr_crc)) {
- noisy_printk(&noise, "jffs3_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n",
- ofs, je16_to_cpu(node->magic),
- je16_to_cpu(node->nodetype),
- je32_to_cpu(node->totlen),
- je32_to_cpu(node->hdr_crc),
- hdr_crc);
+ DBG_NOISY(&noise, "Node at %#08x {0x%04x, 0x%04x, %#08x) has "
+ "invalid CRC %#08x (calculated %#08x)\n",
+ ofs, je16_to_cpu(node->magic), je16_to_cpu(node->nodetype),
+ je32_to_cpu(node->totlen), je32_to_cpu(node->hdr_crc), hdr_crc);
DIRTY_SPACE(4);
ofs += 4;
continue;
@@ -494,9 +504,9 @@
if (ofs + je32_to_cpu(node->totlen) >
jeb->offset + c->sector_size) {
/* Eep. Node goes over the end of the erase block. */
- printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n",
- ofs, je32_to_cpu(node->totlen));
- printk(KERN_WARNING "Perhaps the file system was created with the wrong erase size?\n");
+ WARNING_MSG("Node at %#08x with length %#08x would run over the "
+ "end of the erase block\n", ofs, je32_to_cpu(node->totlen));
+ WARNING_MSG("Perhaps the file system was created ""with the wrong erase size?\n");
DIRTY_SPACE(4);
ofs += 4;
continue;
@@ -504,7 +514,7 @@
if (!(je16_to_cpu(node->nodetype) & JFFS3_NODE_ACCURATE)) {
/* Wheee. This is an obsoleted node */
- D2(printk(KERN_DEBUG "Node at 0x%08x is obsolete. Skipping\n", ofs));
+ DBG_SCAN(2, "Node at %#08x is obsolete. Skipping\n", ofs);
DIRTY_SPACE(PAD(je32_to_cpu(node->totlen)));
ofs += PAD(je32_to_cpu(node->totlen));
continue;
@@ -514,8 +524,9 @@
case JFFS3_NODETYPE_INODE:
if (buf_ofs + buf_len < ofs + sizeof(struct jffs3_raw_inode)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
- D1(printk(KERN_DEBUG "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n",
- sizeof(struct jffs3_raw_inode), buf_len, ofs));
+ DBG_SCAN(1, "Fewer than %zd bytes (inode node left to end "
+ "of buf. Reading %#08x at %#08x\n",
+ sizeof(struct jffs3_raw_inode), buf_len, ofs);
err = jffs3_fill_scan_buf(c, buf, ofs, buf_len);
if (err)
return err;
@@ -530,8 +541,9 @@
case JFFS3_NODETYPE_DIRENT:
if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
- D1(printk(KERN_DEBUG "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n",
- je32_to_cpu(node->totlen), buf_len, ofs));
+ DBG_SCAN(1, "Fewer than %d bytes (dirent node "
+ "left to end of buf. Reading %#08x at %#08x\n",
+ je32_to_cpu(node->totlen), buf_len, ofs);
err = jffs3_fill_scan_buf(c, buf, ofs, buf_len);
if (err)
return err;
@@ -544,20 +556,22 @@
break;
case JFFS3_NODETYPE_CLEANMARKER:
- D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs));
+ DBG_SCAN(1, "CLEANMARKER node found at %#08x\n", ofs);
if (je32_to_cpu(node->totlen) != c->cleanmarker_size) {
- printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n",
+ NOTICE_MSG("CLEANMARKER node found at %#08x has totlen %#08x != normal %#08x\n",
ofs, je32_to_cpu(node->totlen), c->cleanmarker_size);
+ NOTICE_MSG("This may happen if JFFS3 was not cleanly unmounted\n");
DIRTY_SPACE(PAD(sizeof(struct jffs3_unknown_node)));
ofs += PAD(sizeof(struct jffs3_unknown_node));
} else if (jeb->first_node) {
- printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset);
+ WARNING_MSG("CLEANMARKER node found at %#08x, not first node in "
+ "block (%#08x)\n", ofs, jeb->offset);
DIRTY_SPACE(PAD(sizeof(struct jffs3_unknown_node)));
ofs += PAD(sizeof(struct jffs3_unknown_node));
} else {
struct jffs3_raw_node_ref *marker_ref = jffs3_alloc_raw_node_ref();
if (!marker_ref) {
- printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n");
+ ERROR_MSG("Failed to allocate node ref for clean marker\n");
return -ENOMEM;
}
marker_ref->next_in_ino = NULL;
@@ -579,7 +593,8 @@
default:
switch (je16_to_cpu(node->nodetype) & JFFS3_COMPAT_MASK) {
case JFFS3_FEATURE_ROCOMPAT:
- printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs);
+ DBG_SCAN(1, "Read-only compatible feature node (0x%04x) found at "
+ "offset %#08x\n", je16_to_cpu(node->nodetype), ofs);
c->flags |= JFFS3_SB_FLAG_RO;
if (!(jffs3_is_readonly(c)))
return -EROFS;
@@ -588,17 +603,20 @@
break;
case JFFS3_FEATURE_INCOMPAT:
- printk(KERN_NOTICE "Incompatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs);
+ DBG_SCAN(1, "Incompatible feature node (0x%04x) found at offset %#08x\n",
+ je16_to_cpu(node->nodetype), ofs);
return -EINVAL;
case JFFS3_FEATURE_RWCOMPAT_DELETE:
- D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs));
+ DBG_SCAN(1, "Unknown but compatible feature node (0x%04x) found at "
+ "offset %#08x\n", je16_to_cpu(node->nodetype), ofs);
DIRTY_SPACE(PAD(je32_to_cpu(node->totlen)));
ofs += PAD(je32_to_cpu(node->totlen));
break;
case JFFS3_FEATURE_RWCOMPAT_COPY:
- D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs));
+ DBG_SCAN(1, "Unknown but compatible feature node (0x%04x) found at "
+ "offset %#08x\n", je16_to_cpu(node->nodetype), ofs);
USED_SPACE(PAD(je32_to_cpu(node->totlen)));
ofs += PAD(je32_to_cpu(node->totlen));
break;
@@ -606,9 +624,9 @@
}
}
-
- D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset,
- jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size));
+ DBG_SCAN(1, "Block at %#08x: free %#08x, dirty %#08x, unchecked %#08x, "
+ "used %#08x\n", jeb->offset, jeb->free_size, jeb->dirty_size,
+ jeb->unchecked_size, jeb->used_size);
/* mark_node_obsolete can add to wasted !! */
if (jeb->wasted_size) {
@@ -648,7 +666,7 @@
ic = jffs3_alloc_inode_cache();
if (!ic) {
- printk(KERN_NOTICE "jffs3_scan_make_inode_cache(): allocation of inode cache failed\n");
+ ERROR_MSG("Allocation of inode cache failed\n");
return NULL;
}
memset(ic, 0, sizeof(*ic));
@@ -668,7 +686,7 @@
struct jffs3_inode_cache *ic;
uint32_t ino = je32_to_cpu(ri->ino);
- D1(printk(KERN_DEBUG "jffs3_scan_inode_node(): Node at 0x%08x\n", ofs));
+ DBG_SCAN(1, "Node at %#08x\n", ofs);
/* We do very little here now. Just check the ino# to which we should attribute
this node; we can do all the CRC checking etc. later. There's a tradeoff here --
@@ -681,7 +699,7 @@
raw = jffs3_alloc_raw_node_ref();
if (!raw) {
- printk(KERN_NOTICE "jffs3_scan_inode_node(): allocation of node reference failed\n");
+ ERROR_MSG("Allocation of node reference failed\n");
return -ENOMEM;
}
@@ -693,8 +711,9 @@
uint32_t crc = crc32(0, ri, sizeof(*ri)-8);
if (crc != je32_to_cpu(ri->node_crc)) {
- printk(KERN_NOTICE "jffs3_scan_inode_node(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
- ofs, je32_to_cpu(ri->node_crc), crc);
+ NOTICE_MSG("CRC failed on node at %#08x: Read %#08x, calculated %#08x\n",
+ ofs, je32_to_cpu(ri->node_crc), crc);
+ NOTICE_MSG("This may happen if JFFS3 was not cleanly unmounted\n");
/* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */
DIRTY_SPACE(PAD(je32_to_cpu(ri->totlen)));
jffs3_free_raw_node_ref(raw);
@@ -721,10 +740,9 @@
jeb->last_node->next_phys = raw;
jeb->last_node = raw;
- D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
- je32_to_cpu(ri->ino), je32_to_cpu(ri->version),
- je32_to_cpu(ri->offset),
- je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize)));
+ DBG_SCAN(1, "Node is ino #%u, version %d. Range %#08x-%#08x\n",
+ je32_to_cpu(ri->ino), je32_to_cpu(ri->version), je32_to_cpu(ri->offset),
+ je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize));
pseudo_random += je32_to_cpu(ri->version);
@@ -740,15 +758,16 @@
struct jffs3_inode_cache *ic;
uint32_t crc;
- D1(printk(KERN_DEBUG "jffs3_scan_dirent_node(): Node at 0x%08x\n", ofs));
+ DBG_SCAN(1, "Node at %#08x\n", ofs);
/* We don't get here unless the node is still valid, so we don't have to
mask in the ACCURATE bit any more. */
crc = crc32(0, rd, sizeof(*rd)-8);
if (crc != je32_to_cpu(rd->node_crc)) {
- printk(KERN_NOTICE "jffs3_scan_dirent_node(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
- ofs, je32_to_cpu(rd->node_crc), crc);
+ NOTICE_MSG("Node CRC failed on node at %#08x: Read %#08x, calculated %#08x\n",
+ ofs, je32_to_cpu(rd->node_crc), crc);
+ NOTICE_MSG("This may happen if JFFS3 was not cleanly unmounted\n");
/* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */
DIRTY_SPACE(PAD(je32_to_cpu(rd->totlen)));
return 0;
@@ -765,9 +784,11 @@
crc = crc32(0, fd->name, rd->nsize);
if (crc != je32_to_cpu(rd->name_crc)) {
- printk(KERN_NOTICE "jffs3_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
- ofs, je32_to_cpu(rd->name_crc), crc);
- D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino)));
+ NOTICE_MSG("jffs3_scan_dirent_node(): Name CRC failed on node at %#08x: Read %#08x, "
+ "calculated %#08x\n", ofs, je32_to_cpu(rd->name_crc), crc);
+ NOTICE_MSG("This may happen if JFFS3 was not cleanly unmounted\n");
+ DBG_SCAN(1, "Name for which CRC failed is (now) '%s', ino #%d\n",
+ fd->name, je32_to_cpu(rd->ino));
jffs3_free_full_dirent(fd);
/* FIXME: Why do we believe totlen? */
/* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */
@@ -777,7 +798,7 @@
raw = jffs3_alloc_raw_node_ref();
if (!raw) {
jffs3_free_full_dirent(fd);
- printk(KERN_NOTICE "jffs3_scan_dirent_node(): allocation of node reference failed\n");
+ ERROR_MSG("Allocation of node reference failed\n");
return -ENOMEM;
}
ic = jffs3_scan_make_ino_cache(c, je32_to_cpu(rd->pino));
@@ -842,76 +863,76 @@
x = count_list(&c->clean_list);
if (x) {
rotateby = pseudo_random % x;
- D1(printk(KERN_DEBUG "Rotating clean_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating clean_list by %d\n", rotateby);
rotate_list((&c->clean_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of clean_list is at %08x\n",
- list_entry(c->clean_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of clean_list is at %#08x\n",
+ list_entry(c->clean_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty clean_list\n"));
+ DBG_SCAN(1, "Not rotating empty clean_list\n");
}
x = count_list(&c->very_dirty_list);
if (x) {
rotateby = pseudo_random % x;
- D1(printk(KERN_DEBUG "Rotating very_dirty_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating very_dirty_list by %d\n", rotateby);
rotate_list((&c->very_dirty_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of very_dirty_list is at %08x\n",
- list_entry(c->very_dirty_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of very_dirty_list is at %#08x\n",
+ list_entry(c->very_dirty_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty very_dirty_list\n"));
+ DBG_SCAN(1, "Not rotating empty very_dirty_list\n");
}
x = count_list(&c->dirty_list);
if (x) {
rotateby = pseudo_random % x;
- D1(printk(KERN_DEBUG "Rotating dirty_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating dirty_list by %d\n", rotateby);
rotate_list((&c->dirty_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of dirty_list is at %08x\n",
- list_entry(c->dirty_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of dirty_list is at %#08x\n",
+ list_entry(c->dirty_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty dirty_list\n"));
+ DBG_SCAN(1, "Not rotating empty dirty_list\n");
}
x = count_list(&c->erasable_list);
if (x) {
rotateby = pseudo_random % x;
- D1(printk(KERN_DEBUG "Rotating erasable_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating erasable_list by %d\n", rotateby);
rotate_list((&c->erasable_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of erasable_list is at %08x\n",
- list_entry(c->erasable_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of erasable_list is at %#08x\n",
+ list_entry(c->erasable_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty erasable_list\n"));
+ DBG_SCAN(1, "Not rotating empty erasable_list\n");
}
if (c->nr_erasing_blocks) {
rotateby = pseudo_random % c->nr_erasing_blocks;
- D1(printk(KERN_DEBUG "Rotating erase_pending_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating erase_pending_list by %d\n", rotateby);
rotate_list((&c->erase_pending_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of erase_pending_list is at %08x\n",
- list_entry(c->erase_pending_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of erase_pending_list is at %#08x\n",
+ list_entry(c->erase_pending_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty erase_pending_list\n"));
+ DBG_SCAN(1, "Not rotating empty erase_pending_list\n");
}
if (c->nr_free_blocks) {
rotateby = pseudo_random % c->nr_free_blocks;
- D1(printk(KERN_DEBUG "Rotating free_list by %d\n", rotateby));
+ DBG_SCAN(1, "Rotating free_list by %d\n", rotateby);
rotate_list((&c->free_list), rotateby);
- D1(printk(KERN_DEBUG "Erase block at front of free_list is at %08x\n",
- list_entry(c->free_list.next, struct jffs3_eraseblock, list)->offset));
+ DBG_SCAN(1, "Erase block at front of free_list is at %#08x\n",
+ list_entry(c->free_list.next, struct jffs3_eraseblock, list)->offset);
} else {
- D1(printk(KERN_DEBUG "Not rotating empty free_list\n"));
+ DBG_SCAN(1, "Not rotating empty free_list\n");
}
}
More information about the linux-mtd-cvs
mailing list