mtd/fs/jffs3 gc.c,3.2,3.3
Artem Bityuckiy
dedekind at infradead.org
Thu Dec 16 11:55:05 EST 2004
Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv9792
Modified Files:
gc.c
Log Message:
Use output macros.
Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/gc.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- gc.c 13 Dec 2004 15:37:37 -0000 3.2
+++ gc.c 16 Dec 2004 16:55:01 -0000 3.3
@@ -52,37 +52,37 @@
/* We possibly want to favour the dirtier blocks more when the
number of free blocks is low. */
if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) {
- D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n"));
+ DBG_GC("Picking block from bad_used_list to GC next\n");
nextlist = &c->bad_used_list;
} else if (n < 50 && !list_empty(&c->erasable_list)) {
/* Note that most of them will have gone directly to be erased.
So don't favour the erasable_list _too_ much. */
- D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n"));
+ DBG_GC("Picking block from erasable_list to GC next\n");
nextlist = &c->erasable_list;
} else if (n < 110 && !list_empty(&c->very_dirty_list)) {
/* Most of the time, pick one off the very_dirty list */
- D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next\n"));
+ DBG_GC("Picking block from very_dirty_list to GC next\n");
nextlist = &c->very_dirty_list;
} else if (n < 126 && !list_empty(&c->dirty_list)) {
- D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next\n"));
+ DBG_GC("Picking block from dirty_list to GC next\n");
nextlist = &c->dirty_list;
} else if (!list_empty(&c->clean_list)) {
- D1(printk(KERN_DEBUG "Picking block from clean_list to GC next\n"));
+ DBG_GC("Picking block from clean_list to GC next\n");
nextlist = &c->clean_list;
} else if (!list_empty(&c->dirty_list)) {
- D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next (clean_list was empty)\n"));
+ DBG_GC("Picking block from dirty_list to GC next (clean_list was empty)\n");
nextlist = &c->dirty_list;
} else if (!list_empty(&c->very_dirty_list)) {
- D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n"));
+ DBG_GC("Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n");
nextlist = &c->very_dirty_list;
} else if (!list_empty(&c->erasable_list)) {
- D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n"));
+ DBG_GC("Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n");
nextlist = &c->erasable_list;
} else {
/* Eep. All were empty */
- D1(printk(KERN_NOTICE "jffs3: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n"));
+ DBG_GC("No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n");
return NULL;
}
@@ -91,13 +91,13 @@
c->gcblock = ret;
ret->gc_node = ret->first_node;
if (!ret->gc_node) {
- printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset);
+ ERROR_MSG("Eep. ret->gc_node for block at %#08x is NULL\n", ret->offset);
BUG();
}
/* Have we accidentally picked a clean block with wasted space ? */
if (ret->wasted_size) {
- D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size));
+ DBG_GC("Converting wasted_size %#08x to dirty_size\n", ret->wasted_size);
ret->dirty_size += ret->wasted_size;
c->wasted_size -= ret->wasted_size;
c->dirty_size += ret->wasted_size;
@@ -133,7 +133,7 @@
/* checked_ino is protected by the alloc_sem */
if (c->checked_ino > c->highest_ino) {
- printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n",
+ ERROR_MSG("Checked all inodes but still 0x%x bytes of unchecked space?\n",
c->unchecked_size);
D2(jffs3_dbg_dump_block_lists(c));
spin_unlock(&c->erase_completion_lock);
@@ -152,21 +152,20 @@
}
if (!ic->nlink) {
- D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n",
- ic->ino));
+ DBG_GC("Skipping check of ino #%d with nlink zero\n", ic->ino);
spin_unlock(&c->inocache_lock);
continue;
}
switch(ic->state) {
case INO_STATE_CHECKEDABSENT:
case INO_STATE_PRESENT:
- D1(printk(KERN_DEBUG "Skipping ino #%u already checked\n", ic->ino));
+ DBG_GC("Skipping ino #%u already checked\n", ic->ino);
spin_unlock(&c->inocache_lock);
continue;
case INO_STATE_GC:
case INO_STATE_CHECKING:
- printk(KERN_WARNING "Inode #%u is in state %d during CRC check phase!\n", ic->ino, ic->state);
+ ERROR_MSG("Inode #%u is in state %d during CRC check phase!\n", ic->ino, ic->state);
spin_unlock(&c->inocache_lock);
BUG();
@@ -174,7 +173,7 @@
/* We need to wait for it to finish, lest we move on
and trigger the BUG() above while we haven't yet
finished checking all its nodes */
- D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino));
+ DBG_GC("Waiting for ino #%u to finish reading\n", ic->ino);
up(&c->alloc_sem);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
return 0;
@@ -188,11 +187,11 @@
ic->state = INO_STATE_CHECKING;
spin_unlock(&c->inocache_lock);
- D1(printk(KERN_DEBUG "jffs3_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino));
+ DBG_GC("Triggering inode scan of ino#%u\n", ic->ino);
ret = jffs3_do_crccheck_inode(c, ic);
if (ret)
- printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino);
+ WARNING_MSG("Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino);
jffs3_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT);
up(&c->alloc_sem);
@@ -206,15 +205,19 @@
jeb = jffs3_find_gc_block(c);
if (!jeb) {
- D1 (printk(KERN_NOTICE "jffs3: Couldn't find erase block to garbage collect!\n"));
+ DBG_GC("Couldn't find erase block to garbage collect!\n");
spin_unlock(&c->erase_completion_lock);
up(&c->alloc_sem);
return -EIO;
}
- D1(printk(KERN_DEBUG "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size));
- D1(if (c->nextblock)
- printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));
+ DBG_GC("GC from block %#08x, used_size %#08x, dirty_size %#08x, free_size %#08x\n",
+ jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size);
+
+ if (c->nextblock)
+ DBG_GC("Nextblock at %#08x, used_size %#08x, dirty_size %#08x, wasted_size %#08x, free_size %#08x\n",
+ c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size,
+ c->nextblock->wasted_size, c->nextblock->free_size);
if (!jeb->used_size) {
up(&c->alloc_sem);
@@ -224,12 +227,12 @@
raw = jeb->gc_node;
while(ref_obsolete(raw)) {
- D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw)));
+ DBG_GC("Node at %#08x is obsolete... skipping\n", ref_offset(raw));
raw = raw->next_phys;
if (unlikely(!raw)) {
- printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n");
- printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n",
- jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
+ ERROR_MSG("Eep. End of raw list while still supposedly nodes to GC\n");
+ ERROR_MSG("Erase block at %#08x. free_size %#08x, dirty_size %#08x, used_size %#08x\n",
+ jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
jeb->gc_node = raw;
spin_unlock(&c->erase_completion_lock);
up(&c->alloc_sem);
@@ -238,7 +241,7 @@
}
jeb->gc_node = raw;
- D1(printk(KERN_DEBUG "Going to garbage collect node at 0x%08x\n", ref_offset(raw)));
+ DBG_GC("Going to garbage collect node at %#08x\n", ref_offset(raw));
if (!raw->next_in_ino) {
/* Inode-less node. Clean marker, snapshot or something like that */
@@ -259,7 +262,8 @@
spin_unlock(&c->erase_completion_lock);
- D1(printk(KERN_DEBUG "jffs3_garbage_collect_pass collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", jeb->offset, ref_offset(raw), ref_flags(raw), ic->ino));
+ DBG_GC("Collecting from block %#08x. Node %#08x(%d), ino #%u\n",
+ jeb->offset, ref_offset(raw), ref_flags(raw), ic->ino);
/* Three possibilities:
1. Inode is already in-core. We must iget it and do proper
@@ -279,8 +283,7 @@
if (ref_flags(raw) == REF_PRISTINE)
ic->state = INO_STATE_GC;
else {
- D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n",
- ic->ino));
+ DBG_GC("Ino #%u is absent but node not REF_PRISTINE. Reading.\n", ic->ino);
}
break;
@@ -296,8 +299,8 @@
we're holding the alloc_sem, no other garbage collection
can happen.
*/
- printk(KERN_CRIT "Inode #%u already in state %d in jffs3_garbage_collect_pass()!\n",
- ic->ino, ic->state);
+ ERROR_MSG("Inode #%u already in state %d in jffs3_garbage_collect_pass()!\n",
+ ic->ino, ic->state);
up(&c->alloc_sem);
spin_unlock(&c->inocache_lock);
BUG();
@@ -310,8 +313,7 @@
drop the alloc_sem before sleeping. */
up(&c->alloc_sem);
- D1(printk(KERN_DEBUG "jffs3_garbage_collect_pass() waiting for ino #%u in state %d\n",
- ic->ino, ic->state));
+ DBG_GC("Waiting for ino #%u in state %d\n", ic->ino, ic->state);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
/* And because we dropped the alloc_sem we must start again from the
beginning. Ponder chance of livelock here -- we're returning success
@@ -382,7 +384,7 @@
eraseit:
if (c->gcblock && !c->gcblock->used_size) {
- D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset));
+ DBG_GC("Block at %#08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset);
/* We're GC'ing an empty block? */
list_add_tail(&c->gcblock->list, &c->erase_pending_list);
c->gcblock = NULL;
@@ -412,12 +414,12 @@
if (c->gcblock != jeb) {
spin_unlock(&c->erase_completion_lock);
- D1(printk(KERN_DEBUG "GC block is no longer gcblock. Restart\n"));
+ DBG_GC("GC block is no longer gcblock. Restart\n");
goto upnout;
}
if (ref_obsolete(raw)) {
spin_unlock(&c->erase_completion_lock);
- D1(printk(KERN_DEBUG "node to be GC'd was obsoleted in the meantime.\n"));
+ DBG_GC("node to be GC'd was obsoleted in the meantime.\n");
/* They'll call again */
goto upnout;
}
@@ -473,10 +475,10 @@
} else if (fd) {
ret = jffs3_garbage_collect_deletion_dirent(c, jeb, f, fd);
} else {
- printk(KERN_WARNING "Raw node at 0x%08x wasn't in node lists for ino #%u\n",
- ref_offset(raw), f->inocache->ino);
+ WARNINIG_MSG("Raw node at %#08x wasn't in node lists for ino #%u\n",
+ ref_offset(raw), f->inocache->ino);
if (ref_obsolete(raw)) {
- printk(KERN_WARNING "But it's obsolete so we don't mind too much\n");
+ WARNING_MSG("But it's obsolete so we don't mind too much\n");
} else {
ret = -EIO;
}
@@ -499,7 +501,7 @@
uint32_t crc, rawlen;
int retried = 0;
- D1(printk(KERN_DEBUG "Going to GC REF_PRISTINE node at 0x%08x\n", ref_offset(raw)));
+ DBG_GC("Going to GC REF_PRISTINE node at %#08x\n", ref_offset(raw));
rawlen = ref_totlen(c, c->gcblock, raw);
@@ -528,7 +530,7 @@
crc = crc32(0, node, sizeof(struct jffs3_unknown_node)-4);
if (je32_to_cpu(node->u.hdr_crc) != crc) {
- printk(KERN_WARNING "Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+ WARNING_MSG("Header CRC failed on REF_PRISTINE node at %#08x: Read %#08x, calculated %#08x\n",
ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc);
goto bail;
}
@@ -537,7 +539,7 @@
case JFFS3_NODETYPE_INODE:
crc = crc32(0, node, sizeof(node->i)-8);
if (je32_to_cpu(node->i.node_crc) != crc) {
- printk(KERN_WARNING "Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+ WARNING_MSG("Node CRC failed on REF_PRISTINE data node at %#08x: Read %#08x, calculated %#08x\n",
ref_offset(raw), je32_to_cpu(node->i.node_crc), crc);
goto bail;
}
@@ -545,7 +547,7 @@
if (je32_to_cpu(node->i.dsize)) {
crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize));
if (je32_to_cpu(node->i.data_crc) != crc) {
- printk(KERN_WARNING "Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+ WARNING_MSG("Data CRC failed on REF_PRISTINE data node at %#08x: Read %#08x, calculated %#08x\n",
ref_offset(raw), je32_to_cpu(node->i.data_crc), crc);
goto bail;
}
@@ -555,7 +557,7 @@
case JFFS3_NODETYPE_DIRENT:
crc = crc32(0, node, sizeof(node->d)-8);
if (je32_to_cpu(node->d.node_crc) != crc) {
- printk(KERN_WARNING "Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+ WARNING_MSG("Node CRC failed on REF_PRISTINE dirent node at %#08x: Read %#08x, calculated %#08x\n",
ref_offset(raw), je32_to_cpu(node->d.node_crc), crc);
goto bail;
}
@@ -563,14 +565,14 @@
if (node->d.nsize) {
crc = crc32(0, node->d.name, node->d.nsize);
if (je32_to_cpu(node->d.name_crc) != crc) {
- printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent ode at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+ WARNING_MSG("Name CRC failed on REF_PRISTINE dirent ode at %#08x: Read %#08x, calculated %#08x\n",
ref_offset(raw), je32_to_cpu(node->d.name_crc), crc);
goto bail;
}
}
break;
default:
- printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n",
+ WARNING_MSG("Unknown node type for REF_PRISTINE node at %#08x: 0x%04x\n",
ref_offset(raw), je16_to_cpu(node->u.nodetype));
goto bail;
}
@@ -590,8 +592,8 @@
ret = jffs3_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
if (ret || (retlen != rawlen)) {
- printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
- rawlen, phys_ofs, ret, retlen);
+ WARNING_MSG("Write of %d bytes at %#08x failed. returned %d, retlen %zd\n",
+ rawlen, phys_ofs, ret, retlen);
if (retlen) {
/* Doesn't belong to any inode */
nraw->next_in_ino = NULL;
@@ -600,7 +602,8 @@
jffs3_add_physical_node_ref(c, nraw);
jffs3_mark_node_obsolete(c, nraw);
} else {
- printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset);
+ WARNING_MSG("Not marking the space at %#08x as dirty because the flash "
+ "driver returned retlen zero\n", nraw->flash_offset);
jffs3_free_raw_node_ref(nraw);
}
if (!retried && (nraw == jffs3_alloc_raw_node_ref())) {
@@ -610,7 +613,7 @@
retried = 1;
- D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n"));
+ DBG_GC("Retrying failed write of REF_PRISTINE node.\n");
jffs3_dbg_acct_sanity_check(c, jeb);
jffs3_dbg_acct_paranoia_check(c, jeb);
@@ -618,14 +621,14 @@
ret = jffs3_reserve_space_gc(c, rawlen, &phys_ofs, &dummy);
if (!ret) {
- D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs));
+ DBG_GC("Allocated space at %#08x to retry failed write.\n", phys_ofs);
jffs3_dbg_acct_sanity_check(c, jeb);
jffs3_dbg_acct_paranoia_check(c, jeb);
goto retry;
}
- D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret));
+ DBG_GC("Failed to allocate space to retry failed write: %d!\n", ret);
jffs3_free_raw_node_ref(nraw);
}
@@ -647,7 +650,7 @@
spin_unlock(&c->erase_completion_lock);
jffs3_mark_node_obsolete(c, raw);
- D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
+ DBG_GC("WHEEE! GC REF_PRISTINE node at %#08x succeeded\n", ref_offset(raw));
out_node:
kfree(node);
@@ -675,27 +678,27 @@
JFFS3_F_I_RDEV_MIN(f)));
mdata = (char *)&dev;
mdatalen = sizeof(dev);
- D1(printk(KERN_DEBUG "jffs3_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen));
+ DBG_GC("Writing %d bytes of kdev_t\n", mdatalen);
} else if (S_ISLNK(JFFS3_F_I_MODE(f))) {
mdatalen = fn->size;
mdata = kmalloc(fn->size, GFP_KERNEL);
if (!mdata) {
- printk(KERN_WARNING "kmalloc of mdata failed in jffs3_garbage_collect_metadata()\n");
+ WARNING_MSG("kmalloc of mdata failed in jffs3_garbage_collect_metadata()\n");
return -ENOMEM;
}
ret = jffs3_read_dnode(c, f, fn, mdata, 0, mdatalen);
if (ret) {
- printk(KERN_WARNING "read of old metadata failed in jffs3_garbage_collect_metadata(): %d\n", ret);
+ WARNING_MSG("Read of old metadata failed in jffs3_garbage_collect_metadata(): %d\n", ret);
kfree(mdata);
return ret;
}
- D1(printk(KERN_DEBUG "jffs3_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen));
+ DBG_GC("Writing %d bites of symlink target\n", mdatalen);
}
ret = jffs3_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen);
if (ret) {
- printk(KERN_WARNING "jffs3_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n",
+ WARNING_MSG("Reserve space of %zd bytes for garbage_collect_metadata failed: %d\n",
sizeof(ri)+ mdatalen, ret);
goto out;
}
@@ -725,7 +728,7 @@
new_fn = jffs3_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC);
if (IS_ERR(new_fn)) {
- printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
+ WARNING_MSG("Error writing new dnode: %ld\n", PTR_ERR(new_fn));
ret = PTR_ERR(new_fn);
goto out;
}
@@ -762,14 +765,14 @@
ret = jffs3_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen);
if (ret) {
- printk(KERN_WARNING "jffs3_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n",
+ WARNING_MSG("Reserve space of %zd bytes for garbage_collect_dirent failed: %d\n",
sizeof(rd)+rd.nsize, ret);
return ret;
}
new_fd = jffs3_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, ALLOC_GC);
if (IS_ERR(new_fd)) {
- printk(KERN_WARNING "jffs3_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd));
+ WARNING_MSG("Write dirent failed: %ld\n", PTR_ERR(new_fd));
return PTR_ERR(new_fd);
}
jffs3_add_fd_to_list(c, new_fd, &f->dents);
@@ -821,18 +824,18 @@
(fd->raw->flash_offset & ~(c->sector_size-1)))
continue;
- D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw)));
+ DBG_GC("Check potential deletion dirent at %#08x\n", ref_offset(raw));
/* This is an obsolete node belonging to the same directory, and it's of the right
length. We need to take a closer look...*/
ret = jffs3_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd);
if (ret) {
- printk(KERN_WARNING "jffs3_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw));
+ WARNING_MSG("Read error (%d), reading obsolete node at %#08x\n", ret, ref_offset(raw));
/* If we can't read it, we don't need to continue to obsolete it. Continue */
continue;
}
if (retlen != rawlen) {
- printk(KERN_WARNING "jffs3_g_c_deletion_dirent(): Short read (%zd not %u) reading header from obsolete node at %08x\n",
+ WARNING_MSG("Short read (%zd not %u) reading header from obsolete node at %#08x\n",
retlen, rawlen, ref_offset(raw));
continue;
}
@@ -857,8 +860,8 @@
a new deletion dirent to replace it */
up(&c->erase_free_sem);
- D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n",
- ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino)));
+ GBG_GC("Deletion dirent at %#08x still obsoletes real dirent \"%s\" at %#08x for ino #%u\n",
+ ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino));
kfree(rd);
return jffs3_garbage_collect_dirent(c, jeb, f, fd);
@@ -878,7 +881,7 @@
fdp = &(*fdp)->next;
}
if (!found) {
- printk(KERN_WARNING "Deletion dirent \"%s\" not found in list for ino #%u\n", fd->name, f->inocache->ino);
+ WARNING_MSG("Deletion dirent \"%s\" not found in list for ino #%u\n", fd->name, f->inocache->ino);
}
jffs3_mark_node_obsolete(c, fd->raw);
jffs3_free_full_dirent(fd);
@@ -895,8 +898,8 @@
uint32_t alloclen, phys_ofs;
int ret;
- D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
- f->inocache->ino, start, end));
+ DBG_GC("Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
+ f->inocache->ino, start, end);
memset(&ri, 0, sizeof(ri));
@@ -907,35 +910,33 @@
write it out again with the _same_ version as before */
ret = jffs3_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri);
if (readlen != sizeof(ri) || ret) {
- printk(KERN_WARNING "Node read failed in jffs3_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", ret, readlen);
+ WARNING_MSG("Node read failed. Ret %d, retlen %zd. Data will be lost by "
+ "writing new hole node\n", ret, readlen);
goto fill;
}
if (je16_to_cpu(ri.nodetype) != JFFS3_NODETYPE_INODE) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Node at 0x%08x had node type 0x%04x instead of JFFS3_NODETYPE_INODE(0x%04x)\n",
- ref_offset(fn->raw),
- je16_to_cpu(ri.nodetype), JFFS3_NODETYPE_INODE);
+ WARNING_MSG("Node at %#08x had node type 0x%04x instead of JFFS3_NODETYPE_INODE(0x%04x)\n",
+ ref_offset(fn->raw), je16_to_cpu(ri.nodetype), JFFS3_NODETYPE_INODE);
return -EIO;
}
if (je32_to_cpu(ri.totlen) != sizeof(ri)) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n",
- ref_offset(fn->raw),
- je32_to_cpu(ri.totlen), sizeof(ri));
+ WARNING_MSG("Node at %#08x had totlen 0x%x instead of expected 0x%zx\n",
+ ref_offset(fn->raw), je32_to_cpu(ri.totlen), sizeof(ri));
return -EIO;
}
crc = crc32(0, &ri, sizeof(ri)-8);
if (crc != je32_to_cpu(ri.node_crc)) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n",
- ref_offset(fn->raw),
- je32_to_cpu(ri.node_crc), crc);
+ WARNING_MSG("Node at %#08x had CRC %#08x which doesn't match calculated CRC %#08x\n",
+ ref_offset(fn->raw), je32_to_cpu(ri.node_crc), crc);
/* FIXME: We could possibly deal with this by writing new holes for each frag */
- printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n",
- start, end, f->inocache->ino);
+ WARNING_MSG("Data in the range %#08x to %#08x of inode #%u will be lost\n",
+ start, end, f->inocache->ino);
goto fill;
}
if (ri.compr != JFFS3_COMPR_ZERO) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw));
- printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n",
- start, end, f->inocache->ino);
+ WARNING_MSG("Node %#08x wasn't a hole node!\n", ref_offset(fn->raw));
+ WARNING_MSG("Data in the range %#08x to %#08x of inode #%u will be lost\n",
+ start, end, f->inocache->ino);
goto fill;
}
} else {
@@ -964,14 +965,14 @@
ret = jffs3_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen);
if (ret) {
- printk(KERN_WARNING "jffs3_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n",
+ WARNING_MSG("Reserve space of %zd bytes for garbage_collect_hole failed: %d\n",
sizeof(ri), ret);
return ret;
}
new_fn = jffs3_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_GC);
if (IS_ERR(new_fn)) {
- printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn));
+ WARNING_MSG("Error writing new hole node: %ld\n", PTR_ERR(new_fn));
return PTR_ERR(new_fn);
}
if (je32_to_cpu(ri.version) == f->highest_version) {
@@ -990,11 +991,6 @@
* number as before. (Except in case of error -- see 'goto fill;'
* above.)
*/
- D1(if(unlikely(fn->frags <= 1)) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n",
- fn->frags, je32_to_cpu(ri.version), f->highest_version,
- je32_to_cpu(ri.ino));
- });
/* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */
mark_ref_normal(new_fn->raw);
@@ -1010,11 +1006,11 @@
}
}
if (fn->frags) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: Old node still has frags!\n");
+ ERROR_MSG("Old node still has frags!\n");
BUG();
}
if (!new_fn->frags) {
- printk(KERN_WARNING "jffs3_garbage_collect_hole: New node has no frags!\n");
+ ERROR_MSG("New node has no frags!\n");
BUG();
}
@@ -1038,8 +1034,8 @@
memset(&ri, 0, sizeof(ri));
- D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",
- f->inocache->ino, start, end));
+ DBG_GC("Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",
+ f->inocache->ino, start, end);
orig_end = end;
orig_start = start;
@@ -1070,15 +1066,15 @@
/* If the previous frag doesn't even reach the beginning, there's
excessive fragmentation. Just merge. */
if (frag->ofs > min) {
- D1(printk(KERN_DEBUG "Expanding down to cover partial frag (0x%x-0x%x)\n",
- frag->ofs, frag->ofs+frag->size));
+ DBG_GC("Expanding down to cover partial frag (0x%x-0x%x)\n",
+ frag->ofs, frag->ofs+frag->size);
start = frag->ofs;
continue;
}
/* OK. This frag holds the first byte of the page. */
if (!frag->node || !frag->node->raw) {
- D1(printk(KERN_DEBUG "First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
- frag->ofs, frag->ofs+frag->size));
+ DBG_GC("First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
+ frag->ofs, frag->ofs+frag->size);
break;
} else {
@@ -1092,19 +1088,19 @@
jeb = &c->blocks[raw->flash_offset / c->sector_size];
if (jeb == c->gcblock) {
- D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n",
- frag->ofs, frag->ofs+frag->size, ref_offset(raw)));
+ DBG_GC("Expanding down to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
+ frag->ofs, frag->ofs+frag->size, ref_offset(raw));
start = frag->ofs;
break;
}
if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) {
- D1(printk(KERN_DEBUG "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n",
- frag->ofs, frag->ofs+frag->size, jeb->offset));
+ DBG_GC("Not expanding down to cover frag (0x%x-0x%x) in clean block %#08x\n",
+ frag->ofs, frag->ofs+frag->size, jeb->offset);
break;
}
- D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n",
- frag->ofs, frag->ofs+frag->size, jeb->offset));
+ DBG_GC("Expanding down to cover frag (0x%x-0x%x) in dirty block %#08x\n",
+ frag->ofs, frag->ofs+frag->size, jeb->offset);
start = frag->ofs;
break;
}
@@ -1120,15 +1116,15 @@
/* If the previous frag doesn't even reach the beginning, there's lots
of fragmentation. Just merge. */
if (frag->ofs+frag->size < max) {
- D1(printk(KERN_DEBUG "Expanding up to cover partial frag (0x%x-0x%x)\n",
- frag->ofs, frag->ofs+frag->size));
+ DBG_GC("Expanding up to cover partial frag (0x%x-0x%x)\n",
+ frag->ofs, frag->ofs+frag->size);
end = frag->ofs + frag->size;
continue;
}
if (!frag->node || !frag->node->raw) {
- D1(printk(KERN_DEBUG "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n",
- frag->ofs, frag->ofs+frag->size));
+ DBG_GC("Last frag in page is hole (0x%x-0x%x). Not expanding up.\n",
+ frag->ofs, frag->ofs+frag->size);
break;
} else {
@@ -1142,25 +1138,25 @@
jeb = &c->blocks[raw->flash_offset / c->sector_size];
if (jeb == c->gcblock) {
- D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n",
- frag->ofs, frag->ofs+frag->size, ref_offset(raw)));
+ DBG_GC("Expanding up to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
+ frag->ofs, frag->ofs+frag->size, ref_offset(raw));
end = frag->ofs + frag->size;
break;
}
if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) {
- D1(printk(KERN_DEBUG "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n",
- frag->ofs, frag->ofs+frag->size, jeb->offset));
+ DBG_GC("Not expanding up to cover frag (0x%x-0x%x) in clean block %#08x\n",
+ frag->ofs, frag->ofs+frag->size, jeb->offset);
break;
}
- D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n",
- frag->ofs, frag->ofs+frag->size, jeb->offset));
+ DBG_GC("Expanding up to cover frag (0x%x-0x%x) in dirty block %#08x\n",
+ frag->ofs, frag->ofs+frag->size, jeb->offset);
end = frag->ofs + frag->size;
break;
}
}
- D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n",
- orig_start, orig_end, start, end));
+ DBG_GC("Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n",
+ orig_start, orig_end, start, end);
BUG_ON(end > JFFS3_F_I_SIZE(f));
BUG_ON(end < orig_end);
@@ -1177,7 +1173,7 @@
pg_ptr = jffs3_gc_fetch_page(c, f, start, &pg);
if (IS_ERR(pg_ptr)) {
- printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
+ WARNING_MSG("read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
return PTR_ERR(pg_ptr);
}
@@ -1190,7 +1186,7 @@
ret = jffs3_reserve_space_gc(c, sizeof(ri) + JFFS3_MIN_DATA_LEN, &phys_ofs, &alloclen);
if (ret) {
- printk(KERN_WARNING "jffs3_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n",
+ WARNING_MSG("Reserve space of %zd bytes for garbage_collect_dnode failed: %d\n",
sizeof(ri)+ JFFS3_MIN_DATA_LEN, ret);
break;
}
@@ -1228,7 +1224,7 @@
jffs3_free_comprbuf(comprbuf, writebuf);
if (IS_ERR(new_fn)) {
- printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
+ WARNING_MSG("Error writing new dnode: %ld\n", PTR_ERR(new_fn));
ret = PTR_ERR(new_fn);
break;
}
More information about the linux-mtd-cvs
mailing list