mtd/fs/jffs3 wbuf.c,3.2,3.3
Artem Bityuckiy
dedekind at infradead.org
Fri Dec 17 07:18:01 EST 2004
Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv14725
Modified Files:
wbuf.c
Log Message:
Change messaging.
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/wbuf.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- wbuf.c 13 Dec 2004 15:37:37 -0000 3.2
+++ wbuf.c 17 Dec 2004 12:17:58 -0000 3.3
@@ -91,7 +91,7 @@
new = kmalloc(sizeof(*new), GFP_KERNEL);
if (!new) {
- D1(printk(KERN_DEBUG "No memory to allocate inodirty. Fallback to all considered dirty\n"));
+ DBG_WBUF(1, "No memory to allocate inodirty. Fallback to all considered dirty\n");
jffs3_clear_wbuf_ino_list(c);
c->wbuf_inodes = &inodirty_nomem;
return;
@@ -113,19 +113,19 @@
list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) {
struct jffs3_eraseblock *jeb = list_entry(this, struct jffs3_eraseblock, list);
- D1(printk(KERN_DEBUG "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset));
+ DBG_WBUF(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset);
list_del(this);
if ((jiffies + (n++)) & 127) {
/* Most of the time, we just erase it immediately. Otherwise we
spend ages scanning it on mount, etc. */
- D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n"));
+ DBG_WBUF(1, "...and adding to erase_pending_list\n");
list_add_tail(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
jffs3_erase_pending_trigger(c);
} else {
/* Sometimes, however, we leave it elsewhere so it doesn't get
immediately reused, and we spread the load a bit. */
- D1(printk(KERN_DEBUG "...and adding to erasable_list\n"));
+ DBG_WBUF(1, "...and adding to erasable_list\n");
list_add_tail(&jeb->list, &c->erasable_list);
}
}
@@ -133,7 +133,7 @@
static void jffs3_block_refile(struct jffs3_sb_info *c, struct jffs3_eraseblock *jeb)
{
- D1(printk("About to refile bad block at %08x\n", jeb->offset));
+ DBG_WBUF(1, "About to refile bad block at %08x\n", jeb->offset);
D2(jffs3_dbg_dump_block_lists(c));
/* File the existing block on the bad_used_list.... */
@@ -142,12 +142,12 @@
else /* Not sure this should ever happen... need more coffee */
list_del(&jeb->list);
if (jeb->first_node) {
- D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset));
+ DBG_WBUF(1, "Refiling block at %08x to bad_used_list\n", jeb->offset);
list_add(&jeb->list, &c->bad_used_list);
} else {
BUG();
/* It has to have had some nodes or we couldn't be here */
- D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset));
+ DBG_WBUF(1, "Refiling block at %08x to erase_pending_list\n", jeb->offset);
list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
jffs3_erase_pending_trigger(c);
@@ -188,16 +188,15 @@
while (*first_raw &&
(ref_obsolete(*first_raw) ||
(ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) {
- D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n",
+ DBG_WBUF(1, "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n",
ref_offset(*first_raw), ref_flags(*first_raw),
- (ref_offset(*first_raw) + ref_totlen(c, jeb, *first_raw)),
- c->wbuf_ofs));
+ ref_offset(*first_raw) + ref_totlen(c, jeb, *first_raw), c->wbuf_ofs);
first_raw = &(*first_raw)->next_phys;
}
if (!*first_raw) {
/* All nodes were obsolete. Nothing to recover. */
- D1(printk(KERN_DEBUG "No non-obsolete nodes to be recovered. Just filing block bad\n"));
+ DBG_WBUF(1, "No non-obsolete nodes to be recovered. Just filing block bad\n");
spin_unlock(&c->erase_completion_lock);
return;
}
@@ -215,7 +214,7 @@
}
spin_unlock(&c->erase_completion_lock);
- D1(printk(KERN_DEBUG "wbuf recover %08x-%08x\n", start, end));
+ DBG_WBUF(1, "wbuf recover %08x-%08x\n", start, end);
buf = NULL;
if (start < c->wbuf_ofs) {
@@ -224,8 +223,7 @@
buf = kmalloc(end - start, GFP_KERNEL);
if (!buf) {
- printk(KERN_CRIT "Malloc failure in wbuf recovery. Data loss ensues.\n");
-
+ WARNING_MSG("Malloc failure in wbuf recovery. Data loss ensues.\n");
goto read_failed;
}
@@ -240,7 +238,7 @@
ret = 0;
}
if (ret || retlen != c->wbuf_ofs - start) {
- printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n");
+ WARNING_MSG("Old data are already lost in wbuf recovery. Data loss ensues.\n");
kfree(buf);
buf = NULL;
@@ -264,7 +262,7 @@
/* ... and get an allocation of space from a shiny new block instead */
ret = jffs3_reserve_space_gc(c, end-start, &ofs, &len);
if (ret) {
- printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
+ WARNING_MSG("Failed to allocate space for wbuf recovery. Data loss ensues.\n");
if (buf)
kfree(buf);
return;
@@ -278,13 +276,13 @@
uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);
- D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n",
- towrite, ofs));
+ DBG_WBUF(1, "Write 0x%x bytes at 0x%08x in wbuf recover\n",
+ towrite, ofs);
#ifdef BREAKMEHEADER
static int breakme;
if (breakme++ == 20) {
- printk(KERN_NOTICE "Faking write error at 0x%08x\n", ofs);
+ WARNING_MSG("Faking write error at 0x%08x\n", ofs);
breakme = 0;
c->mtd->write_ecc(c->mtd, ofs, towrite, &retlen,
brokenbuf, NULL, c->oobinfo);
@@ -299,7 +297,7 @@
if (ret || retlen != towrite) {
/* Argh. We tried. Really we did. */
- printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n");
+ WARNING_MSG("Recovery of wbuf failed due to a second write error\n");
kfree(buf);
if (retlen) {
@@ -318,7 +316,7 @@
}
return;
}
- printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs);
+ NOTICE_MSG("Recovery of wbuf succeeded to %08x\n", ofs);
c->wbuf_len = (end - start) - towrite;
c->wbuf_ofs = ofs + towrite;
@@ -353,8 +351,8 @@
while (*raw) {
uint32_t rawlen = ref_totlen(c, jeb, *raw);
- D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n",
- rawlen, ref_offset(*raw), ref_flags(*raw), ofs));
+ DBG_WBUF(1, "Refiling block of %08x at %08x(%d) to %08x\n",
+ rawlen, ref_offset(*raw), ref_flags(*raw), ofs);
if (ref_obsolete(*raw)) {
/* Shouldn't really happen much */
@@ -380,7 +378,7 @@
*first_raw = NULL;
if (first_raw == &jeb->first_node) {
jeb->last_node = NULL;
- D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset));
+ DBG_WBUF(1, "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset);
list_del(&jeb->list);
list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
@@ -396,7 +394,7 @@
spin_unlock(&c->erase_completion_lock);
- D1(printk(KERN_DEBUG "wbuf recovery completed OK\n"));
+ DBG_WBUF(1, "wbuf recovery completed OK\n");
}
/* Meaning of pad argument:
@@ -420,7 +418,7 @@
if (!down_trylock(&c->alloc_sem)) {
up(&c->alloc_sem);
- printk(KERN_CRIT "jffs3_flush_wbuf() called with alloc_sem not locked!\n");
+ ERROR_MSG("jffs3_flush_wbuf() called with alloc_sem not locked!\n");
BUG();
}
@@ -454,7 +452,7 @@
#ifdef BREAKME
static int breakme;
if (breakme++ == 20) {
- printk(KERN_NOTICE "Faking write error at 0x%08x\n", c->wbuf_ofs);
+ WARNING_MSG("Faking write error at 0x%08x\n", c->wbuf_ofs);
breakme = 0;
c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize,
&retlen, brokenbuf, NULL, c->oobinfo);
@@ -469,10 +467,9 @@
if (ret || retlen != c->wbuf_pagesize) {
if (ret)
- printk(KERN_WARNING "jffs3_flush_wbuf(): Write failed with %d\n",ret);
+ WARNING_MSG("Write failed with %d\n",ret);
else {
- printk(KERN_WARNING "jffs3_flush_wbuf(): Write was short: %zd instead of %d\n",
- retlen, c->wbuf_pagesize);
+ WARNING_MSG("Write was short: %zd instead of %d\n", retlen, c->wbuf_pagesize);
ret = -EIO;
}
@@ -489,19 +486,11 @@
jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
- D1(printk(KERN_DEBUG "jffs3_flush_wbuf() adjusting free_size of %sblock at %08x\n",
- (jeb==c->nextblock)?"next":"", jeb->offset));
+ DBG_WBUF(1, "adjusting free_size of %sblock at %08x\n",
+ (jeb==c->nextblock)?"next":"", jeb->offset);
+
+ jffs3_dbg_wbuf_acct_sanity_check(c, jeb);
- /* wbuf_pagesize - wbuf_len is the amount of space that's to be
- padded. If there is less free space in the block than that,
- something screwed up */
- if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
- printk(KERN_CRIT "jffs3_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
- c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len);
- printk(KERN_CRIT "jffs3_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
- jeb->offset, jeb->free_size);
- BUG();
- }
jeb->free_size -= (c->wbuf_pagesize - c->wbuf_len);
c->free_size -= (c->wbuf_pagesize - c->wbuf_len);
jeb->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
@@ -530,11 +519,11 @@
uint32_t old_wbuf_len;
int ret = 0;
- D1(printk(KERN_DEBUG "jffs3_flush_wbuf_gc() called for ino #%u...\n", ino));
+ DBG_WBUF(1, "Ino #%u...\n", ino);
down(&c->alloc_sem);
if (!jffs3_wbuf_pending_for_ino(c, ino)) {
- D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino));
+ DBG_WBUF(1, "Ino #%d not pending in wbuf. Returning\n", ino);
up(&c->alloc_sem);
return 0;
}
@@ -544,7 +533,7 @@
if (c->unchecked_size) {
/* GC won't make any progress for a while */
- D1(printk(KERN_DEBUG "jffs3_flush_wbuf_gc() padding. Not finished checking\n"));
+ DBG_WBUF(1, "Padding. Not finished checking\n");
down_write(&c->wbuf_sem);
ret = __jffs3_flush_wbuf(c, PAD_ACCOUNTING);
up_write(&c->wbuf_sem);
@@ -553,7 +542,7 @@
up(&c->alloc_sem);
- D1(printk(KERN_DEBUG "jffs3_flush_wbuf_gc() calls gc pass\n"));
+ DBG_WBUF(1, "Call gc pass\n");
ret = jffs3_garbage_collect_pass(c);
if (ret) {
@@ -567,7 +556,7 @@
down(&c->alloc_sem);
}
- D1(printk(KERN_DEBUG "jffs3_flush_wbuf_gc() ends...\n"));
+ DBG_WBUF(1, "End...\n");
up(&c->alloc_sem);
return ret;
@@ -633,11 +622,11 @@
if ( (to & ~(c->sector_size-1)) != (c->wbuf_ofs & ~(c->sector_size-1)) ) {
/* It's a write to a new block */
if (c->wbuf_len) {
- D1(printk(KERN_DEBUG "jffs3_flash_writev() to 0x%lx causes flush of wbuf at 0x%08x\n", (unsigned long)to, c->wbuf_ofs));
+ DBG_WBUF(1, "writev to 0x%lx causes flush of wbuf at 0x%08x\n", (unsigned long)to, c->wbuf_ofs);
ret = __jffs3_flush_wbuf(c, PAD_NOACCOUNT);
if (ret) {
/* the underlying layer has to check wbuf_len to do the cleanup */
- D1(printk(KERN_WARNING "jffs3_flush_wbuf() called from jffs3_flash_writev() failed %d\n", ret));
+ WARNING_MSG("called from jffs3_flash_writev() failed %d\n", ret);
*retlen = 0;
goto exit;
}
@@ -649,16 +638,16 @@
if (to != PAD(c->wbuf_ofs + c->wbuf_len)) {
/* We're not writing immediately after the writebuffer. Bad. */
- printk(KERN_CRIT "jffs3_flash_writev(): Non-contiguous write to %08lx\n", (unsigned long)to);
+ ERROR_MSG("Non-contiguous write to %08lx\n", (unsigned long)to);
if (c->wbuf_len)
- printk(KERN_CRIT "wbuf was previously %08x-%08x\n",
+ ERROR_MSG("wbuf was previously %08x-%08x\n",
c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len);
BUG();
}
/* Note outvecs[3] above. We know count is never greater than 2 */
if (count > 2) {
- printk(KERN_CRIT "jffs3_flash_writev(): count is %ld\n", count);
+ ERROR_MSG("jffs3_flash_writev(): count is %ld\n", count);
BUG();
}
@@ -702,7 +691,7 @@
ret = __jffs3_flush_wbuf(c, NOPAD);
if (ret) {
/* the underlying layer has to check wbuf_len to do the cleanup */
- D1(printk(KERN_WARNING "jffs3_flush_wbuf() called from jffs3_flash_writev() failed %d\n", ret));
+ WARNING_MSG("called from jffs3_flash_writev() failed %d\n", ret);
/* Retlen zero to make sure our caller doesn't mark the space dirty.
We've already done everything that's necessary */
*retlen = 0;
@@ -845,8 +834,7 @@
ret = c->mtd->read(c->mtd, ofs, len, retlen, buf);
if ( (ret == -EBADMSG) && (*retlen == len) ) {
- printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n",
- len, ofs);
+ WARNING_MSG("mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", len, ofs);
/*
* We have the raw data without ECC correction in the buffer, maybe
* we are lucky and all data or parts are correct. We check the node.
@@ -909,7 +897,7 @@
len = 4 * oob_size;
buf = kmalloc(len, GFP_KERNEL);
if (!buf) {
- printk(KERN_NOTICE "jffs3_check_oob_empty(): allocation of temporary data buffer for oob check failed\n");
+ WARNING_MSG("Allocation of temporary data buffer for oob check failed\n");
return -ENOMEM;
}
/*
@@ -918,13 +906,13 @@
*/
ret = jffs3_flash_read_oob(c, jeb->offset, len , &retlen, buf);
if (ret) {
- D1(printk(KERN_WARNING "jffs3_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset));
+ WARNING_MSG("Read OOB failed %d for block at %08x\n", ret, jeb->offset);
goto out;
}
if (retlen < len) {
- D1(printk(KERN_WARNING "jffs3_check_oob_empty(): Read OOB return short read "
- "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset));
+ WARNING_MSG("jffs3_check_oob_empty(): Read OOB return short read "
+ "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset);
ret = -EIO;
goto out;
}
@@ -937,8 +925,7 @@
continue;
if (buf[i] != 0xFF) {
- D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",
- buf[i], i, jeb->offset));
+ DBG_WBUF(2, "Found %02x at %x in OOB for %08x\n", buf[i], i, jeb->offset);
ret = 1;
goto out;
}
@@ -981,7 +968,7 @@
for (cnt = 0; cnt < (c->sector_size / c->mtd->erasesize); cnt++) {
/* Check first if the block is bad. */
if (c->mtd->block_isbad (c->mtd, offset)) {
- D1 (printk (KERN_WARNING "jffs3_check_nand_cleanmarker(): Bad block at %08x\n", jeb->offset));
+ DBG_WBUF("Bad block at %08x\n", jeb->offset);
return 2;
}
/*
@@ -992,11 +979,12 @@
ret = c->mtd->read_oob (c->mtd, offset, oob_size << 1, &retlen, buf);
if (ret) {
- D1 (printk (KERN_WARNING "jffs3_check_nand_cleanmarker(): Read OOB failed %d for block at %08x\n", ret, jeb->offset));
+ DBG_WBUF("Read OOB failed %d for block at %08x\n", ret, jeb->offset);
return ret;
}
if (retlen < (oob_size << 1)) {
- D1 (printk (KERN_WARNING "jffs3_check_nand_cleanmarker(): Read OOB return short read (%zd bytes not %d) for block at %08x\n", retlen, oob_size << 1, jeb->offset));
+ DBG_WBUF("Read OOB return short read (%zd bytes not %d) for block at %08x\n",
+ retlen, oob_size << 1, jeb->offset);
return -EIO;
}
@@ -1012,14 +1000,12 @@
retval = 1;
}
}
- D1(if (retval == 1) {
- printk(KERN_WARNING "jffs3_check_nand_cleanmarker(): Cleanmarker node not detected in block at %08x\n", jeb->offset);
- printk(KERN_WARNING "OOB at %08x was ", offset);
- for (i=0; i < oob_size; i++) {
- printk("%02x ", buf[i]);
- }
- printk("\n");
- })
+
+ if (retval == 1) {
+ DBG_WBUF(1, "Cleanmarker node not detected in block at %08x\n", jeb->offset);
+ DBG_WBUF(1, "OOB at %08x was ", offset);
+ D1(jffs3_dbg_dump_buffer(buf, oob_size, 0));
+ }
}
offset += c->mtd->erasesize;
}
@@ -1039,11 +1025,11 @@
ret = jffs3_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n);
if (ret) {
- D1(printk(KERN_WARNING "jffs3_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret));
+ WARNING_MSG("Write failed for block at %08x: error %d\n", jeb->offset, ret);
return ret;
}
if (retlen != c->fsdata_len) {
- D1(printk(KERN_WARNING "jffs3_write_nand_cleanmarker(): Short write for block at %08x: %zd not %d\n", jeb->offset, retlen, c->fsdata_len));
+ WARNING_MSG("Short write for block at %08x: %zd not %d\n", jeb->offset, retlen, c->fsdata_len);
return ret;
}
return 0;
@@ -1068,11 +1054,11 @@
if (!c->mtd->block_markbad)
return 1; // What else can we do?
- D1(printk(KERN_WARNING "jffs3_write_nand_badblock(): Marking bad block at %08x\n", bad_offset));
+ NOTICE_MSG("jffs3_write_nand_badblock(): Marking bad block at %08x\n", bad_offset);
ret = c->mtd->block_markbad(c->mtd, bad_offset);
if (ret) {
- D1(printk(KERN_WARNING "jffs3_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret));
+ WARNING_MSG("Write failed for block at %08x: error %d\n", jeb->offset, ret);
return ret;
}
return 1;
@@ -1100,10 +1086,10 @@
/* Should we use autoplacement ? */
if (oinfo && oinfo->useecc == MTD_NANDECC_AUTOPLACE) {
- D1(printk(KERN_DEBUG "JFFS3 using autoplace on NAND\n"));
+ DBG_WBUF(1, "JFFS3 using autoplace on NAND\n");
/* Get the position of the free bytes */
if (!oinfo->oobfree[0][1]) {
- printk (KERN_WARNING "jffs3_nand_set_oobinfo(): Eeep. Autoplacement selected and no empty space in oob\n");
+ WARNING_MSG("Eeep. Autoplacement selected and no empty space in oob\n");
return -ENOSPC;
}
c->fsdata_pos = oinfo->oobfree[0][0];
@@ -1114,7 +1100,7 @@
/* This is just a legacy fallback and should go away soon */
switch(c->mtd->ecctype) {
case MTD_ECC_RS_DiskOnChip:
- printk(KERN_WARNING "JFFS3 using DiskOnChip hardware ECC without autoplacement. Fix it!\n");
+ WARNING_MSG("JFFS3 using DiskOnChip hardware ECC without autoplacement. Fix it!\n");
c->oobinfo = &jffs3_oobinfo_docecc;
c->fsdata_pos = 6;
c->fsdata_len = NAND_JFFS3_OOB16_FSDALEN;
@@ -1122,7 +1108,7 @@
break;
default:
- D1(printk(KERN_DEBUG "JFFS3 on NAND. No autoplacment info found\n"));
+ DBG_WBUF(1, "JFFS3 on NAND. No autoplacment info found\n");
return -EINVAL;
}
}
More information about the linux-mtd-cvs
mailing list