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

[JFFS2] Debug code simplification, update TODO

Simplify the debugging code further.
Update the TODO list
Signed-off-by: default avatarArtem B. Bityutskiy <dedekind@infradead.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent b523b3ba
$Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ $Id: TODO,v 1.18 2005/09/22 11:24:56 dedekind Exp $
- support asynchronous operation -- add a per-fs 'reserved_space' count,
let each outstanding write reserve the _maximum_ amount of physical
space it could take. Let GC flush the outstanding writes because the
reservations will necessarily be pessimistic. With this we could even
do shared writable mmap, if we can have a fs hook for do_wp_page() to
make the reservation.
- disable compression in commit_write()? - disable compression in commit_write()?
- fine-tune the allocation / GC thresholds - fine-tune the allocation / GC thresholds
- chattr support - turning on/off and tuning compression per-inode - chattr support - turning on/off and tuning compression per-inode
...@@ -11,26 +17,15 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ ...@@ -11,26 +17,15 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $
- test, test, test - test, test, test
- NAND flash support: - NAND flash support:
- flush_wbuf using GC to fill it, don't just pad. - almost done :)
- Deal with write errors. Data don't get lost - we just have to write - use bad block check instead of the hardwired byte check
the affected node(s) out again somewhere else.
- make fsync flush only if actually required
- make sys_sync() work.
- reboot notifier
- timed flush of old wbuf
- fix magical second arg of jffs2_flush_wbuf(). Split into two or more functions instead.
- Optimisations: - Optimisations:
- Stop GC from decompressing and immediately recompressing nodes which could - Split writes so they go to two separate blocks rather than just c->nextblock.
just be copied intact. (We now keep track of REF_PRISTINE flag. Easy now.) By writing _new_ nodes to one block, and garbage-collected REF_PRISTINE
- Furthermore, in the case where it could be copied intact we don't even need nodes to a different one, we can separate clean nodes from those which
to call iget() for it -- if we use (raw_node_raw->flash_offset & 2) as a flag are likely to become dirty, and end up with blocks which are each far
to show a node can be copied intact and it's _not_ in icache, we could just do closer to 100% or 0% clean, hence speeding up later GC progress dramatically.
it, fix up the next_in_ino list and move on. We would need a way to find out
_whether_ it's in icache though -- if it's in icache we also need to do the
fragment lists, etc. P'raps a flag or pointer in the jffs2_inode_cache could
help. (We have half of this now.)
- Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in - Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in
the full dirent, we only need to go to the flash in lookup() when we think we've the full dirent, we only need to go to the flash in lookup() when we think we've
got a match, and in readdir(). got a match, and in readdir().
...@@ -38,3 +33,8 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ ...@@ -38,3 +33,8 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $
- Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into - Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into
jffs2_mark_node_obsolete(). Can all callers work it out? jffs2_mark_node_obsolete(). Can all callers work it out?
- Remove size from jffs2_raw_node_frag. - Remove size from jffs2_raw_node_frag.
dedekind:
1. __jffs2_flush_wbuf() has a strange 'pad' parameter. Eliminate.
2. get_sb()->build_fs()->scan() path... Why get_sb() removes scan()'s crap in
case of failure? scan() does not clean everything. Fix.
...@@ -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.79 2005/09/07 11:21:57 havasi Exp $ * $Id: build.c,v 1.83 2005/09/21 15:52:33 dedekind Exp $
* *
*/ */
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include "nodelist.h" #include "nodelist.h"
static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **); static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *,
struct jffs2_inode_cache *, struct jffs2_full_dirent **);
static inline struct jffs2_inode_cache * static inline struct jffs2_inode_cache *
first_inode_chain(int *i, struct jffs2_sb_info *c) first_inode_chain(int *i, struct jffs2_sb_info *c)
...@@ -46,11 +47,12 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c) ...@@ -46,11 +47,12 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
ic = next_inode(&i, ic, (c))) ic = next_inode(&i, ic, (c)))
static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
struct jffs2_inode_cache *ic)
{ {
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
D1(printk(KERN_DEBUG "jffs2_build_inode building directory inode #%u\n", ic->ino)); dbg_fsbuild("building directory inode #%u\n", ic->ino);
/* For each child, increase nlink */ /* For each child, increase nlink */
for(fd = ic->scan_dents; fd; fd = fd->next) { for(fd = ic->scan_dents; fd; fd = fd->next) {
...@@ -58,26 +60,23 @@ static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2 ...@@ -58,26 +60,23 @@ static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2
if (!fd->ino) if (!fd->ino)
continue; continue;
/* XXX: Can get high latency here with huge directories */ /* we can get high latency here with huge directories */
child_ic = jffs2_get_ino_cache(c, fd->ino); child_ic = jffs2_get_ino_cache(c, fd->ino);
if (!child_ic) { if (!child_ic) {
printk(KERN_NOTICE "Eep. Child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n", dbg_fsbuild("child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n",
fd->name, fd->ino, ic->ino); fd->name, fd->ino, ic->ino);
jffs2_mark_node_obsolete(c, fd->raw); jffs2_mark_node_obsolete(c, fd->raw);
continue; continue;
} }
if (child_ic->nlink++ && fd->type == DT_DIR) { if (child_ic->nlink++ && fd->type == DT_DIR) {
printk(KERN_NOTICE "Child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", fd->name, fd->ino, ic->ino); JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n",
if (fd->ino == 1 && ic->ino == 1) { fd->name, fd->ino, ic->ino);
printk(KERN_NOTICE "This is mostly harmless, and probably caused by creating a JFFS2 image\n"); /* TODO: What do we do about it? */
printk(KERN_NOTICE "using a buggy version of mkfs.jffs2. Use at least v1.17.\n");
}
/* What do we do about it? */
} }
D1(printk(KERN_DEBUG "Increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino)); dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino);
/* Can't free them. We might need them in pass 2 */ /* Can't free scan_dents so far. We might need them in pass 2 */
} }
} }
...@@ -94,6 +93,8 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -94,6 +93,8 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
struct jffs2_full_dirent *dead_fds = NULL; struct jffs2_full_dirent *dead_fds = NULL;
dbg_fsbuild("build FS data structures\n");
/* First, scan the medium and build all the inode caches with /* First, scan the medium and build all the inode caches with
lists of physical nodes */ lists of physical nodes */
...@@ -103,33 +104,29 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -103,33 +104,29 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
if (ret) if (ret)
goto exit; goto exit;
D1(printk(KERN_DEBUG "Scanned flash completely\n")); dbg_fsbuild("scanned flash completely\n");
jffs2_dbg_dump_block_lists_nolock(c); jffs2_dbg_dump_block_lists_nolock(c);
dbg_fsbuild("pass 1 starting\n");
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. */
for_each_inode(i, c, ic) { for_each_inode(i, c, ic) {
D1(printk(KERN_DEBUG "Pass 1: ino #%u\n", ic->ino));
D1(BUG_ON(ic->ino > c->highest_ino));
if (ic->scan_dents) { if (ic->scan_dents) {
jffs2_build_inode_pass1(c, ic); jffs2_build_inode_pass1(c, ic);
cond_resched(); cond_resched();
} }
} }
D1(printk(KERN_DEBUG "Pass 1 complete\n")); dbg_fsbuild("pass 1 complete\n");
/* Next, scan for inodes with nlink == 0 and remove them. If /* Next, scan for inodes with nlink == 0 and remove them. If
they were directories, then decrement the nlink of their they were directories, then decrement the nlink of their
children too, and repeat the scan. As that's going to be children too, and repeat the scan. As that's going to be
a fairly uncommon occurrence, it's not so evil to do it this a fairly uncommon occurrence, it's not so evil to do it this
way. Recursion bad. */ way. Recursion bad. */
D1(printk(KERN_DEBUG "Pass 2 starting\n")); dbg_fsbuild("pass 2 starting\n");
for_each_inode(i, c, ic) { for_each_inode(i, c, ic) {
D1(printk(KERN_DEBUG "Pass 2: ino #%u, nlink %d, ic %p, nodes %p\n", ic->ino, ic->nlink, ic, ic->nodes));
if (ic->nlink) if (ic->nlink)
continue; continue;
...@@ -137,26 +134,24 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -137,26 +134,24 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
cond_resched(); cond_resched();
} }
D1(printk(KERN_DEBUG "Pass 2a starting\n")); dbg_fsbuild("pass 2a starting\n");
while (dead_fds) { while (dead_fds) {
fd = dead_fds; fd = dead_fds;
dead_fds = fd->next; dead_fds = fd->next;
ic = jffs2_get_ino_cache(c, fd->ino); ic = jffs2_get_ino_cache(c, fd->ino);
D1(printk(KERN_DEBUG "Removing dead_fd ino #%u (\"%s\"), ic at %p\n", fd->ino, fd->name, ic));
if (ic) if (ic)
jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); jffs2_build_remove_unlinked_inode(c, ic, &dead_fds);
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
} }
D1(printk(KERN_DEBUG "Pass 2 complete\n")); dbg_fsbuild("pass 2a complete\n");
dbg_fsbuild("freeing temporary data structures\n");
/* Finally, we can scan again and free the dirent structs */ /* Finally, we can scan again and free the dirent structs */
for_each_inode(i, c, ic) { for_each_inode(i, c, ic) {
D1(printk(KERN_DEBUG "Pass 3: ino #%u, ic %p, nodes %p\n", ic->ino, ic, ic->nodes));
while(ic->scan_dents) { while(ic->scan_dents) {
fd = ic->scan_dents; fd = ic->scan_dents;
ic->scan_dents = fd->next; ic->scan_dents = fd->next;
...@@ -167,8 +162,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -167,8 +162,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")); dbg_fsbuild("FS build complete\n");
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);
...@@ -189,24 +183,26 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ...@@ -189,24 +183,26 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
return ret; return ret;
} }
static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, struct jffs2_full_dirent **dead_fds) static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c,
struct jffs2_inode_cache *ic,
struct jffs2_full_dirent **dead_fds)
{ {
struct jffs2_raw_node_ref *raw; struct jffs2_raw_node_ref *raw;
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
D1(printk(KERN_DEBUG "JFFS2: Removing ino #%u with nlink == zero.\n", ic->ino)); dbg_fsbuild("removing ino #%u with nlink == zero.\n", ic->ino);
raw = ic->nodes; raw = ic->nodes;
while (raw != (void *)ic) { while (raw != (void *)ic) {
struct jffs2_raw_node_ref *next = raw->next_in_ino; struct jffs2_raw_node_ref *next = raw->next_in_ino;
D1(printk(KERN_DEBUG "obsoleting node at 0x%08x\n", ref_offset(raw))); dbg_fsbuild("obsoleting node at 0x%08x\n", ref_offset(raw));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
raw = next; raw = next;
} }
if (ic->scan_dents) { if (ic->scan_dents) {
int whinged = 0; int whinged = 0;
D1(printk(KERN_DEBUG "Inode #%u was a directory which may have children...\n", ic->ino)); dbg_fsbuild("inode #%u was a directory which may have children...\n", ic->ino);
while(ic->scan_dents) { while(ic->scan_dents) {
struct jffs2_inode_cache *child_ic; struct jffs2_inode_cache *child_ic;
...@@ -216,21 +212,19 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf ...@@ -216,21 +212,19 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf
if (!fd->ino) { if (!fd->ino) {
/* It's a deletion dirent. Ignore it */ /* It's a deletion dirent. Ignore it */
D1(printk(KERN_DEBUG "Child \"%s\" is a deletion dirent, skipping...\n", fd->name)); dbg_fsbuild("child \"%s\" is a deletion dirent, skipping...\n", fd->name);
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
continue; continue;
} }
if (!whinged) { if (!whinged)
whinged = 1; whinged = 1;
printk(KERN_NOTICE "Inode #%u was a directory with children - removing those too...\n", ic->ino);
}
D1(printk(KERN_DEBUG "Removing child \"%s\", ino #%u\n", dbg_fsbuild("removing child \"%s\", ino #%u\n", fd->name, fd->ino);
fd->name, fd->ino));
child_ic = jffs2_get_ino_cache(c, fd->ino); child_ic = jffs2_get_ino_cache(c, fd->ino);
if (!child_ic) { if (!child_ic) {
printk(KERN_NOTICE "Cannot remove child \"%s\", ino #%u, because it doesn't exist\n", fd->name, fd->ino); dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n",
fd->name, fd->ino);
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
continue; continue;
} }
...@@ -241,13 +235,13 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf ...@@ -241,13 +235,13 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf
child_ic->nlink--; child_ic->nlink--;
if (!child_ic->nlink) { if (!child_ic->nlink) {
D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got zero nlink. Adding to dead_fds list.\n", dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n",
fd->ino, fd->name)); fd->ino, fd->name);
fd->next = *dead_fds; fd->next = *dead_fds;
*dead_fds = fd; *dead_fds = fd;
} else { } else {
D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n",
fd->ino, fd->name, child_ic->nlink)); fd->ino, fd->name, child_ic->nlink);
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
} }
} }
...@@ -295,20 +289,20 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) ...@@ -295,20 +289,20 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c)
trying to GC to make more space. It'll be a fruitless task */ trying to GC to make more space. It'll be a fruitless task */
c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); c->nospc_dirty_size = c->sector_size + (c->flash_size / 100);
D1(printk(KERN_DEBUG "JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", dbg_fsbuild("JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n",
c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks)); c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks);
D1(printk(KERN_DEBUG "Blocks required to allow deletion: %d (%d KiB)\n", dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n",
c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024)); c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024);
D1(printk(KERN_DEBUG "Blocks required to allow writes: %d (%d KiB)\n", dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n",
c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024)); c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024);
D1(printk(KERN_DEBUG "Blocks required to quiesce GC thread: %d (%d KiB)\n", dbg_fsbuild("Blocks required to quiesce GC thread: %d (%d KiB)\n",
c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024)); c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024);
D1(printk(KERN_DEBUG "Blocks required to allow GC merges: %d (%d KiB)\n", dbg_fsbuild("Blocks required to allow GC merges: %d (%d KiB)\n",
c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024)); c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024);
D1(printk(KERN_DEBUG "Blocks required to GC bad blocks: %d (%d KiB)\n", dbg_fsbuild("Blocks required to GC bad blocks: %d (%d KiB)\n",
c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024)); c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024);
D1(printk(KERN_DEBUG "Amount of dirty space required to GC: %d bytes\n", dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n",
c->nospc_dirty_size)); c->nospc_dirty_size);
} }
int jffs2_do_mount_fs(struct jffs2_sb_info *c) int jffs2_do_mount_fs(struct jffs2_sb_info *c)
...@@ -358,7 +352,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) ...@@ -358,7 +352,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
return ret; return ret;
if (jffs2_build_filesystem(c)) { if (jffs2_build_filesystem(c)) {
D1(printk(KERN_DEBUG "build_fs failed\n")); dbg_fsbuild("build_fs failed\n");
jffs2_free_ino_caches(c); jffs2_free_ino_caches(c);
jffs2_free_raw_node_refs(c); jffs2_free_raw_node_refs(c);
#ifndef __ECOS #ifndef __ECOS
......
...@@ -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.c,v 1.10 2005/09/14 16:57:32 dedekind Exp $ * $Id: debug.c,v 1.11 2005/09/21 13:28:35 dedekind Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/jffs2.h> #include <linux/jffs2.h>
#include <linux/mtd/mtd.h>
#include "nodelist.h" #include "nodelist.h"
#include "debug.h" #include "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: debug.h,v 1.16 2005/09/14 16:57:32 dedekind Exp $ * $Id: debug.h,v 1.18 2005/09/21 10:26:26 dedekind Exp $
* *
*/ */
#ifndef _JFFS2_DEBUG_H_ #ifndef _JFFS2_DEBUG_H_
...@@ -23,16 +23,23 @@ ...@@ -23,16 +23,23 @@
/* Enable "paranoia" checks and dumps */ /* Enable "paranoia" checks and dumps */
#define JFFS2_DBG_PARANOIA_CHECKS #define JFFS2_DBG_PARANOIA_CHECKS
#define JFFS2_DBG_DUMPS #define JFFS2_DBG_DUMPS
/*
* By defining/undefining the below macros one may select debugging messages
* fro specific JFFS2 subsystems.
*/
#define JFFS2_DBG_READINODE_MESSAGES #define JFFS2_DBG_READINODE_MESSAGES
#define JFFS2_DBG_FRAGTREE_MESSAGES #define JFFS2_DBG_FRAGTREE_MESSAGES
#define JFFS2_DBG_DENTLIST_MESSAGES #define JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_NODEREF_MESSAGES #define JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_INOCACHE_MESSAGES #define JFFS2_DBG_INOCACHE_MESSAGES
#define JFFS2_DBG_SUMMARY_MESSAGES #define JFFS2_DBG_SUMMARY_MESSAGES
#define JFFS2_DBG_FSBUILD_MESSAGES
#endif #endif
#if CONFIG_JFFS2_FS_DEBUG == 2 #if CONFIG_JFFS2_FS_DEBUG == 2
#define JFFS2_DBG_FRAGTREE2_MESSAGES #define JFFS2_DBG_FRAGTREE2_MESSAGES
#define JFFS2_DBG_MEMALLOC_MESSAGES
#endif #endif
/* Sanity checks are supposed to be light-weight and enabled by default */ /* Sanity checks are supposed to be light-weight and enabled by default */
...@@ -40,7 +47,7 @@ ...@@ -40,7 +47,7 @@
/* /*
* Dx() are mainly used for debugging messages, they must go away and be * Dx() are mainly used for debugging messages, they must go away and be
* superseded by nicer JFFS2_DBG_XXX() macros... * superseded by nicer dbg_xxx() macros...
*/ */
#if CONFIG_JFFS2_FS_DEBUG > 0 #if CONFIG_JFFS2_FS_DEBUG > 0
#define D1(x) x #define D1(x) x
...@@ -105,56 +112,63 @@ ...@@ -105,56 +112,63 @@
*/ */
/* Read inode debugging messages */ /* Read inode debugging messages */
#ifdef JFFS2_DBG_READINODE_MESSAGES #ifdef JFFS2_DBG_READINODE_MESSAGES
#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_READINODE(fmt, ...) #define dbg_readinode(fmt, ...)
#endif #endif
/* Fragtree build debugging messages */ /* Fragtree build debugging messages */
#ifdef JFFS2_DBG_FRAGTREE_MESSAGES #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
#define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_FRAGTREE(fmt, ...) #define dbg_fragtree(fmt, ...)
#endif #endif
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_FRAGTREE2(fmt, ...) #define dbg_fragtree2(fmt, ...)
#endif #endif
/* Directory entry list manilulation debugging messages */ /* Directory entry list manilulation debugging messages */
#ifdef JFFS2_DBG_DENTLIST_MESSAGES #ifdef JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_DENTLIST(fmt, ...) #define dbg_dentlist(fmt, ...)
#endif #endif
/* Print the messages about manipulating node_refs */ /* Print the messages about manipulating node_refs */
#ifdef JFFS2_DBG_NODEREF_MESSAGES #ifdef JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_NODEREF(fmt, ...) #define dbg_noderef(fmt, ...)
#endif #endif
/* Manipulations with the list of inodes (JFFS2 inocache) */ /* Manipulations with the list of inodes (JFFS2 inocache) */
#ifdef JFFS2_DBG_INOCACHE_MESSAGES #ifdef JFFS2_DBG_INOCACHE_MESSAGES
#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_INOCACHE(fmt, ...) #define dbg_inocache(fmt, ...)
#endif #endif
/* Summary debugging messages */ /* Summary debugging messages */
#ifdef JFFS2_DBG_SUMMARY_MESSAGES #ifdef JFFS2_DBG_SUMMARY_MESSAGES
#define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_summary(fmt, ...)
#endif
/* File system build messages */
#ifdef JFFS2_DBG_FSBUILD_MESSAGES
#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_SUMMARY(fmt, ...) #define dbg_fsbuild(fmt, ...)
#endif #endif
/* Watch the object allocations */ /* Watch the object allocations */
#ifdef JFFS2_DBG_MEMALLOC_MESSAGES #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
#define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) #define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else #else
#define JFFS2_DBG_MEMALLOC(fmt, ...) #define dbg_memalloc(fmt, ...)
#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: erase.c,v 1.83 2005/07/22 10:32:08 dedekind Exp $ * $Id: erase.c,v 1.85 2005/09/20 14:53:15 dedekind Exp $
* *
*/ */
......
...@@ -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: malloc.c,v 1.29 2005/07/27 14:16:53 dedekind Exp $ * $Id: malloc.c,v 1.30 2005/09/20 14:27:34 dedekind Exp $
* *
*/ */
...@@ -97,13 +97,13 @@ struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize) ...@@ -97,13 +97,13 @@ struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize)
{ {
struct jffs2_full_dirent *ret; struct jffs2_full_dirent *ret;
ret = kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL); ret = kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_full_dirent(struct jffs2_full_dirent *x) void jffs2_free_full_dirent(struct jffs2_full_dirent *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kfree(x); kfree(x);
} }
...@@ -111,13 +111,13 @@ struct jffs2_full_dnode *jffs2_alloc_full_dnode(void) ...@@ -111,13 +111,13 @@ struct jffs2_full_dnode *jffs2_alloc_full_dnode(void)
{ {
struct jffs2_full_dnode *ret; struct jffs2_full_dnode *ret;
ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL); ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_full_dnode(struct jffs2_full_dnode *x) void jffs2_free_full_dnode(struct jffs2_full_dnode *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(full_dnode_slab, x); kmem_cache_free(full_dnode_slab, x);
} }
...@@ -125,13 +125,13 @@ struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void) ...@@ -125,13 +125,13 @@ struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void)
{ {
struct jffs2_raw_dirent *ret; struct jffs2_raw_dirent *ret;
ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL); ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x) void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(raw_dirent_slab, x); kmem_cache_free(raw_dirent_slab, x);
} }
...@@ -139,13 +139,13 @@ struct jffs2_raw_inode *jffs2_alloc_raw_inode(void) ...@@ -139,13 +139,13 @@ struct jffs2_raw_inode *jffs2_alloc_raw_inode(void)
{ {
struct jffs2_raw_inode *ret; struct jffs2_raw_inode *ret;
ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL); ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_raw_inode(struct jffs2_raw_inode *x) void jffs2_free_raw_inode(struct jffs2_raw_inode *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(raw_inode_slab, x); kmem_cache_free(raw_inode_slab, x);
} }
...@@ -153,14 +153,14 @@ struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void) ...@@ -153,14 +153,14 @@ struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void)
{ {
struct jffs2_tmp_dnode_info *ret; struct jffs2_tmp_dnode_info *ret;
ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL); ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", dbg_memalloc("%p\n",
ret); ret);
return ret; return ret;
} }
void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x) void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(tmp_dnode_info_slab, x); kmem_cache_free(tmp_dnode_info_slab, x);
} }
...@@ -168,13 +168,13 @@ struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void) ...@@ -168,13 +168,13 @@ struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void)
{ {
struct jffs2_raw_node_ref *ret; struct jffs2_raw_node_ref *ret;
ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(raw_node_ref_slab, x); kmem_cache_free(raw_node_ref_slab, x);
} }
...@@ -182,13 +182,13 @@ struct jffs2_node_frag *jffs2_alloc_node_frag(void) ...@@ -182,13 +182,13 @@ struct jffs2_node_frag *jffs2_alloc_node_frag(void)
{ {
struct jffs2_node_frag *ret; struct jffs2_node_frag *ret;
ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL); ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_node_frag(struct jffs2_node_frag *x) void jffs2_free_node_frag(struct jffs2_node_frag *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(node_frag_slab, x); kmem_cache_free(node_frag_slab, x);
} }
...@@ -196,12 +196,12 @@ struct jffs2_inode_cache *jffs2_alloc_inode_cache(void) ...@@ -196,12 +196,12 @@ struct jffs2_inode_cache *jffs2_alloc_inode_cache(void)
{ {
struct jffs2_inode_cache *ret; struct jffs2_inode_cache *ret;
ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL); ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL);
JFFS2_DBG_MEMALLOC("%p\n", ret); dbg_memalloc("%p\n", ret);
return ret; return ret;
} }
void jffs2_free_inode_cache(struct jffs2_inode_cache *x) void jffs2_free_inode_cache(struct jffs2_inode_cache *x)
{ {
JFFS2_DBG_MEMALLOC("%p\n", x); dbg_memalloc("%p\n", x);
kmem_cache_free(inode_cache_slab, x); kmem_cache_free(inode_cache_slab, x);
} }
...@@ -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.112 2005/08/22 09:07:09 dedekind Exp $ * $Id: nodelist.c,v 1.114 2005/09/21 13:28:35 dedekind Exp $
* *
*/ */
...@@ -25,18 +25,18 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new ...@@ -25,18 +25,18 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
{ {
struct jffs2_full_dirent **prev = list; struct jffs2_full_dirent **prev = list;
JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino); dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino);
while ((*prev) && (*prev)->nhash <= new->nhash) { while ((*prev) && (*prev)->nhash <= new->nhash) {
if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
/* Duplicate. Free one */ /* Duplicate. Free one */
if (new->version < (*prev)->version) { if (new->version < (*prev)->version) {
JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n", dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
(*prev)->name, (*prev)->ino); (*prev)->name, (*prev)->ino);
jffs2_mark_node_obsolete(c, new->raw); jffs2_mark_node_obsolete(c, new->raw);
jffs2_free_full_dirent(new); jffs2_free_full_dirent(new);
} else { } else {
JFFS2_DBG_DENTLIST("marking old dirent \"%s\", ino #%u bsolete\n", dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n",
(*prev)->name, (*prev)->ino); (*prev)->name, (*prev)->ino);
new->next = (*prev)->next; new->next = (*prev)->next;
jffs2_mark_node_obsolete(c, ((*prev)->raw)); jffs2_mark_node_obsolete(c, ((*prev)->raw));
...@@ -55,7 +55,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint ...@@ -55,7 +55,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
{ {
struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size); dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size);
/* We know frag->ofs <= size. That's what lookup does for us */ /* We know frag->ofs <= size. That's what lookup does for us */
if (frag && frag->ofs != size) { if (frag && frag->ofs != size) {
...@@ -81,7 +81,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint ...@@ -81,7 +81,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
*/ */
frag = frag_last(list); frag = frag_last(list);
if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) { if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {
JFFS2_DBG_FRAGTREE2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n", dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",
frag->ofs, frag->ofs + frag->size); frag->ofs, frag->ofs + frag->size);
frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE; frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE;
} }
...@@ -93,12 +93,12 @@ void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *t ...@@ -93,12 +93,12 @@ void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *t
this->node->frags--; this->node->frags--;
if (!this->node->frags) { if (!this->node->frags) {
/* The node has no valid frags left. It's totally obsoleted */ /* The node has no valid frags left. It's totally obsoleted */
JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n", dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size); ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size);
jffs2_mark_node_obsolete(c, this->node->raw); jffs2_mark_node_obsolete(c, this->node->raw);
jffs2_free_full_dnode(this->node); jffs2_free_full_dnode(this->node);
} else { } else {
JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n", dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n",
ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags); ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags);
mark_ref_normal(this->node->raw); mark_ref_normal(this->node->raw);
} }
...@@ -112,7 +112,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_ ...@@ -112,7 +112,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_
struct rb_node *parent = &base->rb; struct rb_node *parent = &base->rb;
struct rb_node **link = &parent; struct rb_node **link = &parent;
JFFS2_DBG_FRAGTREE2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size);
while (*link) { while (*link) {
parent = *link; parent = *link;
...@@ -172,11 +172,11 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root, ...@@ -172,11 +172,11 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
/* By definition, the 'this' node has no right-hand child, /* By definition, the 'this' node has no right-hand child,
because there are no frags with offset greater than it. because there are no frags with offset greater than it.
So that's where we want to put the hole */ So that's where we want to put the hole */
JFFS2_DBG_FRAGTREE2("add hole frag %#04x-%#04x on the right of the new frag.\n", dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n",
holefrag->ofs, holefrag->ofs + holefrag->size); holefrag->ofs, holefrag->ofs + holefrag->size);
rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right); rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right);
} else { } else {
JFFS2_DBG_FRAGTREE2("Add hole frag %#04x-%#04x to the root of the tree.\n", dbg_fragtree2("Add hole frag %#04x-%#04x to the root of the tree.\n",
holefrag->ofs, holefrag->ofs + holefrag->size); holefrag->ofs, holefrag->ofs + holefrag->size);
rb_link_node(&holefrag->rb, NULL, &root->rb_node); rb_link_node(&holefrag->rb, NULL, &root->rb_node);
} }
...@@ -188,10 +188,10 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root, ...@@ -188,10 +188,10 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
/* By definition, the 'this' node has no right-hand child, /* By definition, the 'this' node has no right-hand child,
because there are no frags with offset greater than it. because there are no frags with offset greater than it.
So that's where we want to put new fragment */ So that's where we want to put new fragment */
JFFS2_DBG_FRAGTREE2("add the new node at the right\n"); dbg_fragtree2("add the new node at the right\n");
rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
} else { } else {
JFFS2_DBG_FRAGTREE2("insert the new node at the root of the tree\n"); dbg_fragtree2("insert the new node at the root of the tree\n");
rb_link_node(&newfrag->rb, NULL, &root->rb_node); rb_link_node(&newfrag->rb, NULL, &root->rb_node);
} }
rb_insert_color(&newfrag->rb, root); rb_insert_color(&newfrag->rb, root);
...@@ -209,11 +209,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r ...@@ -209,11 +209,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
this = jffs2_lookup_node_frag(root, newfrag->node->ofs); this = jffs2_lookup_node_frag(root, newfrag->node->ofs);
if (this) { if (this) {
JFFS2_DBG_FRAGTREE2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", dbg_fragtree2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this); this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this);
lastend = this->ofs + this->size; lastend = this->ofs + this->size;
} else { } else {
JFFS2_DBG_FRAGTREE2("lookup gave no frag\n"); dbg_fragtree2("lookup gave no frag\n");
lastend = 0; lastend = 0;
} }
...@@ -235,11 +235,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r ...@@ -235,11 +235,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
} }
if (this->node) if (this->node)
JFFS2_DBG_FRAGTREE2("dealing with frag %u-%u, phys %#08x(%d).\n", dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n",
this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size,
ref_offset(this->node->raw), ref_flags(this->node->raw)); ref_offset(this->node->raw), ref_flags(this->node->raw));
else else
JFFS2_DBG_FRAGTREE2("dealing with hole frag %u-%u.\n", dbg_fragtree2("dealing with hole frag %u-%u.\n",
this->ofs, this->ofs + this->size); this->ofs, this->ofs + this->size);
/* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes,
...@@ -259,10 +259,10 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r ...@@ -259,10 +259,10 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
struct jffs2_node_frag *newfrag2; struct jffs2_node_frag *newfrag2;
if (this->node) if (this->node)
JFFS2_DBG_FRAGTREE2("split old frag 0x%04x-0x%04x, phys 0x%08x\n", dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",
this->ofs, this->ofs+this->size, ref_offset(this->node->raw)); this->ofs, this->ofs+this->size, ref_offset(this->node->raw));
else else
JFFS2_DBG_FRAGTREE2("split old hole frag 0x%04x-0x%04x\n", dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n",
this->ofs, this->ofs+this->size); this->ofs, this->ofs+this->size);
/* New second frag pointing to this's node */ /* New second frag pointing to this's node */
...@@ -299,13 +299,13 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r ...@@ -299,13 +299,13 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
} else { } else {
/* New frag starts at the same point as 'this' used to. Replace /* New frag starts at the same point as 'this' used to. Replace
it in the tree without doing a delete and insertion */ it in the tree without doing a delete and insertion */
JFFS2_DBG_FRAGTREE2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",
newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size);
rb_replace_node(&this->rb, &newfrag->rb, root); rb_replace_node(&this->rb, &newfrag->rb, root);
if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { if (newfrag->ofs + newfrag->size >= this->ofs+this->size) {
JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size); dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);
jffs2_obsolete_node_frag(c, this); jffs2_obsolete_node_frag(c, this);
} else { } else {
this->ofs += newfrag->size; this->ofs += newfrag->size;
...@@ -321,7 +321,7 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r ...@@ -321,7 +321,7 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
*/ */
while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) {
/* 'this' frag is obsoleted completely. */ /* 'this' frag is obsoleted completely. */
JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x) and removing from tree\n", dbg_fragtree2("obsoleting node frag %p (%x-%x) and removing from tree\n",
this, this->ofs, this->ofs+this->size); this, this->ofs, this->ofs+this->size);
rb_erase(&this->rb, root); rb_erase(&this->rb, root);
jffs2_obsolete_node_frag(c, this); jffs2_obsolete_node_frag(c, this);
...@@ -361,7 +361,7 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in ...@@ -361,7 +361,7 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
return -ENOMEM; return -ENOMEM;
newfrag->node->frags = 1; newfrag->node->frags = 1;
JFFS2_DBG_FRAGTREE("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",
fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);
...@@ -410,14 +410,17 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info ...@@ -410,14 +410,17 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
BUG_ON(tn->csize == 0); BUG_ON(tn->csize == 0);
if (!jffs2_is_writebuffered(c))
goto adj_acc;
/* Calculate how many bytes were already checked */ /* Calculate how many bytes were already checked */
ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
len = ofs & (c->wbuf_pagesize - 1); len = ofs % c->wbuf_pagesize;
if (likely(len)) if (likely(len))
len = c->wbuf_pagesize - len; len = c->wbuf_pagesize - len;
if (len >= tn->csize) { if (len >= tn->csize) {
JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
ref_offset(ref), tn->csize, ofs); ref_offset(ref), tn->csize, ofs);
goto adj_acc; goto adj_acc;
} }
...@@ -425,7 +428,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info ...@@ -425,7 +428,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
ofs += len; ofs += len;
len = tn->csize - len; len = tn->csize - len;
JFFS2_DBG_READINODE("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",
ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len);
#ifndef __ECOS #ifndef __ECOS
...@@ -520,7 +523,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f ...@@ -520,7 +523,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
if (ref_flags(tn->fn->raw) != REF_UNCHECKED) if (ref_flags(tn->fn->raw) != REF_UNCHECKED)
return 0; return 0;
JFFS2_DBG_FRAGTREE2("check node %#04x-%#04x, phys offs %#08x.\n", dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n",
tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw));
ret = check_node_data(c, tn); ret = check_node_data(c, tn);
...@@ -528,7 +531,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f ...@@ -528,7 +531,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
JFFS2_ERROR("check_node_data() returned error: %d.\n", JFFS2_ERROR("check_node_data() returned error: %d.\n",
ret); ret);
} else if (unlikely(ret > 0)) { } else if (unlikely(ret > 0)) {
JFFS2_DBG_FRAGTREE2("CRC error, mark it obsolete.\n"); dbg_fragtree2("CRC error, mark it obsolete.\n");
jffs2_mark_node_obsolete(c, tn->fn->raw); jffs2_mark_node_obsolete(c, tn->fn->raw);
} }
...@@ -544,7 +547,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f ...@@ -544,7 +547,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole) struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole)
{ {
JFFS2_DBG_FRAGTREE2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n", dbg_fragtree2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n",
newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size); newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size);
if (hole->ofs == newfrag->ofs) { if (hole->ofs == newfrag->ofs) {
...@@ -558,7 +561,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, ...@@ -558,7 +561,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
* the new node. * the new node.
*/ */
JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and cut the left part of the hole\n", dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n",
newfrag->ofs, newfrag->ofs + newfrag->size); newfrag->ofs, newfrag->ofs + newfrag->size);
rb_replace_node(&hole->rb, &newfrag->rb, root); rb_replace_node(&hole->rb, &newfrag->rb, root);
...@@ -576,7 +579,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, ...@@ -576,7 +579,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
* Ah, the new fragment is of the same size as the hole. * Ah, the new fragment is of the same size as the hole.
* Relace the hole by it. * Relace the hole by it.
*/ */
JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and overwrite hole\n", dbg_fragtree2("insert fragment %#04x-%#04x and overwrite hole\n",
newfrag->ofs, newfrag->ofs + newfrag->size); newfrag->ofs, newfrag->ofs + newfrag->size);
rb_replace_node(&hole->rb, &newfrag->rb, root); rb_replace_node(&hole->rb, &newfrag->rb, root);
jffs2_free_node_frag(hole); jffs2_free_node_frag(hole);
...@@ -598,14 +601,14 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, ...@@ -598,14 +601,14 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
} }
hole->size = newfrag->ofs - hole->ofs; hole->size = newfrag->ofs - hole->ofs;
JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n", dbg_fragtree2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n",
hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size); hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size);
jffs2_fragtree_insert(newfrag, hole); jffs2_fragtree_insert(newfrag, hole);
rb_insert_color(&newfrag->rb, root); rb_insert_color(&newfrag->rb, root);
if (newfrag2) { if (newfrag2) {
JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the right\n", dbg_fragtree2("left the hole %#04x-%#04x at the right\n",
newfrag2->ofs, newfrag2->ofs + newfrag2->size); newfrag2->ofs, newfrag2->ofs + newfrag2->size);
jffs2_fragtree_insert(newfrag2, newfrag); jffs2_fragtree_insert(newfrag2, newfrag);
rb_insert_color(&newfrag2->rb, root); rb_insert_color(&newfrag2->rb, root);
...@@ -640,12 +643,12 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -640,12 +643,12 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
int err, checked = 0; int err, checked = 0;
int ref_flag; int ref_flag;
JFFS2_DBG_FRAGTREE("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version); dbg_fragtree("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version);
/* Skip all the nodes which are completed before this one starts */ /* Skip all the nodes which are completed before this one starts */
this = jffs2_lookup_node_frag(root, fn_ofs); this = jffs2_lookup_node_frag(root, fn_ofs);
if (this) if (this)
JFFS2_DBG_FRAGTREE2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole"); dbg_fragtree2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole");
if (this) if (this)
lastend = this->ofs + this->size; lastend = this->ofs + this->size;
...@@ -745,7 +748,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -745,7 +748,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
* The new node starts at the same offset as * The new node starts at the same offset as
* the hole and supersieds the hole. * the hole and supersieds the hole.
*/ */
JFFS2_DBG_FRAGTREE2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n", dbg_fragtree2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n",
fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
rb_replace_node(&this->rb, &newfrag->rb, root); rb_replace_node(&this->rb, &newfrag->rb, root);
...@@ -755,10 +758,10 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -755,10 +758,10 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
* The hole becomes shorter as its right part * The hole becomes shorter as its right part
* is supersieded by the new fragment. * is supersieded by the new fragment.
*/ */
JFFS2_DBG_FRAGTREE2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n", dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",
this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size); this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size);
JFFS2_DBG_FRAGTREE2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs, dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,
fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
this->size -= newfrag->size; this->size -= newfrag->size;
...@@ -771,7 +774,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -771,7 +774,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
this = rb_entry(rb_next(&newfrag->rb), this = rb_entry(rb_next(&newfrag->rb),
struct jffs2_node_frag, rb); struct jffs2_node_frag, rb);
JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
} }
...@@ -782,7 +785,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -782,7 +785,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
if (this->ofs + this->size >= fn_ofs + fn_size) { if (this->ofs + this->size >= fn_ofs + fn_size) {
/* The new node is obsolete, drop it */ /* The new node is obsolete, drop it */
if (fn->frags == 0) { if (fn->frags == 0) {
JFFS2_DBG_FRAGTREE2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size); dbg_fragtree2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size);
ref_flag = REF_OBSOLETE; ref_flag = REF_OBSOLETE;
} }
goto out_ok; goto out_ok;
...@@ -790,13 +793,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -790,13 +793,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
struct jffs2_node_frag *new_this; struct jffs2_node_frag *new_this;
/* 'This' node obsoletes the beginning of the new node */ /* 'This' node obsoletes the beginning of the new node */
JFFS2_DBG_FRAGTREE2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size); dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);
ref_flag = REF_NORMAL; ref_flag = REF_NORMAL;
fn_size -= this->ofs + this->size - fn_ofs; fn_size -= this->ofs + this->size - fn_ofs;
fn_ofs = this->ofs + this->size; fn_ofs = this->ofs + this->size;
JFFS2_DBG_FRAGTREE2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size); dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);
new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb); new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb);
if (!new_this) { if (!new_this) {
...@@ -816,14 +819,14 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -816,14 +819,14 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
if (unlikely(!newfrag)) if (unlikely(!newfrag))
return -ENOMEM; return -ENOMEM;
JFFS2_DBG_FRAGTREE2("there are no more fragments, insert %#04x-%#04x\n", dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n",
newfrag->ofs, newfrag->ofs + newfrag->size); newfrag->ofs, newfrag->ofs + newfrag->size);
rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
rb_insert_color(&newfrag->rb, root); rb_insert_color(&newfrag->rb, root);
goto out_ok; goto out_ok;
} else { } else {
this = new_this; this = new_this;
JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
} }
} }
...@@ -833,13 +836,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode ...@@ -833,13 +836,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE); BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE);
if (ref_flag == REF_OBSOLETE) { if (ref_flag == REF_OBSOLETE) {
JFFS2_DBG_FRAGTREE2("the node is obsolete now\n"); dbg_fragtree2("the node is obsolete now\n");
/* jffs2_mark_node_obsolete() will adjust space accounting */ /* jffs2_mark_node_obsolete() will adjust space accounting */
jffs2_mark_node_obsolete(c, fn->raw); jffs2_mark_node_obsolete(c, fn->raw);
return 1; return 1;
} }
JFFS2_DBG_FRAGTREE2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE"); dbg_fragtree2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE");
/* Space accounting was adjusted at check_node_data() */ /* Space accounting was adjusted at check_node_data() */
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
...@@ -885,7 +888,7 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new ...@@ -885,7 +888,7 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new
if (!new->ino) if (!new->ino)
new->ino = ++c->highest_ino; new->ino = ++c->highest_ino;
JFFS2_DBG_INOCACHE("add %p (ino #%u)\n", new, new->ino); dbg_inocache("add %p (ino #%u)\n", new, new->ino);
prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE]; prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
...@@ -902,7 +905,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old) ...@@ -902,7 +905,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
{ {
struct jffs2_inode_cache **prev; struct jffs2_inode_cache **prev;
JFFS2_DBG_INOCACHE("del %p (ino #%u)\n", old, old->ino); dbg_inocache("del %p (ino #%u)\n", old, old->ino);
spin_lock(&c->inocache_lock); spin_lock(&c->inocache_lock);
prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
...@@ -965,7 +968,7 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_ ...@@ -965,7 +968,7 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
struct jffs2_node_frag *prev = NULL; struct jffs2_node_frag *prev = NULL;
struct jffs2_node_frag *frag = NULL; struct jffs2_node_frag *frag = NULL;
JFFS2_DBG_FRAGTREE2("root %p, offset %d\n", fragtree, offset); dbg_fragtree2("root %p, offset %d\n", fragtree, offset);
next = fragtree->rb_node; next = fragtree->rb_node;
...@@ -988,10 +991,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_ ...@@ -988,10 +991,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
and return the closest smaller one */ and return the closest smaller one */
if (prev) if (prev)
JFFS2_DBG_FRAGTREE2("no match. Returning frag %#04x-%#04x, closest previous\n", dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n",
prev->ofs, prev->ofs+prev->size); prev->ofs, prev->ofs+prev->size);
else else
JFFS2_DBG_FRAGTREE2("returning NULL, empty fragtree\n"); dbg_fragtree2("returning NULL, empty fragtree\n");
return prev; return prev;
} }
...@@ -1006,7 +1009,7 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) ...@@ -1006,7 +1009,7 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
if (!root->rb_node) if (!root->rb_node)
return; return;
JFFS2_DBG_FRAGTREE("killing\n"); dbg_fragtree("killing\n");
frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
while(frag) { while(frag) {
......
...@@ -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.126 2005/09/16 12:58:17 havasi Exp $ * $Id: nodemgmt.c,v 1.127 2005/09/20 15:49:12 dedekind Exp $
* *
*/ */
...@@ -273,7 +273,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -273,7 +273,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
if (jeb) { if (jeb) {
reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE); reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE);
JFFS2_DBG_SUMMARY("minsize=%d , jeb->free=%d ," dbg_summary("minsize=%d , jeb->free=%d ,"
"summary->size=%d , sumsize=%d\n", "summary->size=%d , sumsize=%d\n",
minsize, jeb->free_size, minsize, jeb->free_size,
c->summary->sum_size, sumsize); c->summary->sum_size, sumsize);
...@@ -291,7 +291,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -291,7 +291,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
} }
/* Writing out the collected summary information */ /* Writing out the collected summary information */
JFFS2_DBG_SUMMARY("generating summary for 0x%08x.\n", jeb->offset); dbg_summary("generating summary for 0x%08x.\n", jeb->offset);
ret = jffs2_sum_write_sumnode(c); ret = jffs2_sum_write_sumnode(c);
if (ret) if (ret)
......
...@@ -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: os-linux.h,v 1.61 2005/09/07 08:34:54 havasi Exp $ * $Id: os-linux.h,v 1.63 2005/09/21 11:55:21 dedekind Exp $
* *
*/ */
...@@ -80,8 +80,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) ...@@ -80,8 +80,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
#define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf) #define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf)
#define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) #define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf))
#define jffs2_flush_wbuf_pad(c) ({ (void)(c), 0; }) #define jffs2_flush_wbuf_pad(c) ({ do{} while(0); (void)(c), 0; })
#define jffs2_flush_wbuf_gc(c, i) ({ (void)(c), (void) i, 0; }) #define jffs2_flush_wbuf_gc(c, i) ({ do{} while(0); (void)(c), (void) i, 0; })
#define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) #define jffs2_write_nand_badblock(c,jeb,bad_offset) (1)
#define jffs2_nand_flash_setup(c) (0) #define jffs2_nand_flash_setup(c) (0)
#define jffs2_nand_flash_cleanup(c) do {} while(0) #define jffs2_nand_flash_cleanup(c) do {} while(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: readinode.c,v 1.141 2005/08/17 14:57:39 dedekind Exp $ * $Id: readinode.c,v 1.142 2005/09/20 14:27:34 dedekind Exp $
* *
*/ */
...@@ -97,7 +97,7 @@ static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_r ...@@ -97,7 +97,7 @@ static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_r
while (ref && ref->next_in_ino) { while (ref && ref->next_in_ino) {
if (!ref_obsolete(ref)) if (!ref_obsolete(ref))
return ref; return ref;
JFFS2_DBG_NODEREF("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref)); dbg_noderef("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref));
ref = ref->next_in_ino; ref = ref->next_in_ino;
} }
return NULL; return NULL;
...@@ -274,7 +274,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -274,7 +274,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
len = min_t(uint32_t, rdlen - sizeof(*rd), csize); len = min_t(uint32_t, rdlen - sizeof(*rd), csize);
tn->partial_crc = crc32(0, buf, len); tn->partial_crc = crc32(0, buf, len);
JFFS2_DBG_READINODE("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize); dbg_readinode("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize);
/* If we actually calculated the whole data CRC /* If we actually calculated the whole data CRC
* and it is wrong, drop the node. */ * and it is wrong, drop the node. */
...@@ -293,7 +293,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -293,7 +293,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
*/ */
struct jffs2_eraseblock *jeb; struct jffs2_eraseblock *jeb;
JFFS2_DBG_READINODE("the node has no data.\n"); dbg_readinode("the node has no data.\n");
jeb = &c->blocks[ref->flash_offset / c->sector_size]; jeb = &c->blocks[ref->flash_offset / c->sector_size];
len = ref_totlen(c, jeb, ref); len = ref_totlen(c, jeb, ref);
...@@ -327,7 +327,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -327,7 +327,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
else // normal case... else // normal case...
tn->fn->size = je32_to_cpu(rd->dsize); tn->fn->size = je32_to_cpu(rd->dsize);
JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n", dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",
ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize); ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);
jffs2_add_tn_to_tree(tn, tnp); jffs2_add_tn_to_tree(tn, tnp);
...@@ -424,7 +424,7 @@ static int read_more(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref, ...@@ -424,7 +424,7 @@ static int read_more(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref,
len = right_size - *rdlen; len = right_size - *rdlen;
} }
JFFS2_DBG_READINODE("read more %d bytes\n", len); dbg_readinode("read more %d bytes\n", len);
err = jffs2_flash_read(c, offs, len, &retlen, bufstart); err = jffs2_flash_read(c, offs, len, &retlen, bufstart);
if (err) { if (err) {
...@@ -461,7 +461,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf ...@@ -461,7 +461,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
*mctime_ver = 0; *mctime_ver = 0;
JFFS2_DBG_READINODE("ino #%u\n", f->inocache->ino); dbg_readinode("ino #%u\n", f->inocache->ino);
if (jffs2_is_writebuffered(c)) { if (jffs2_is_writebuffered(c)) {
/* /*
...@@ -531,7 +531,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf ...@@ -531,7 +531,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
len = JFFS2_MIN_NODE_HEADER; len = JFFS2_MIN_NODE_HEADER;
} }
JFFS2_DBG_READINODE("read %d bytes at %#08x(%d).\n", len, ref_offset(ref), ref_flags(ref)); dbg_readinode("read %d bytes at %#08x(%d).\n", len, ref_offset(ref), ref_flags(ref));
/* FIXME: point() */ /* FIXME: point() */
err = jffs2_flash_read(c, ref_offset(ref), len, err = jffs2_flash_read(c, ref_offset(ref), len,
...@@ -614,7 +614,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf ...@@ -614,7 +614,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
*fdp = ret_fd; *fdp = ret_fd;
kfree(buf); kfree(buf);
JFFS2_DBG_READINODE("nodes of inode #%u were read, the highest version is %u, latest_mctime %u, mctime_ver %u.\n", dbg_readinode("nodes of inode #%u were read, the highest version is %u, latest_mctime %u, mctime_ver %u.\n",
f->inocache->ino, *highest_version, *latest_mctime, *mctime_ver); f->inocache->ino, *highest_version, *latest_mctime, *mctime_ver);
return 0; return 0;
...@@ -639,7 +639,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -639,7 +639,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
size_t retlen; size_t retlen;
int ret; int ret;
JFFS2_DBG_READINODE("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink); dbg_readinode("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink);
/* Grab all nodes relevant to this ino */ /* Grab all nodes relevant to this ino */
ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver); ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver);
...@@ -659,7 +659,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -659,7 +659,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb); tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb);
fn = tn->fn; fn = tn->fn;
ret = 1; ret = 1;
JFFS2_DBG_READINODE("consider node ver %u, phys offset " dbg_readinode("consider node ver %u, phys offset "
"%#08x(%d), range %u-%u.\n", tn->version, "%#08x(%d), range %u-%u.\n", tn->version,
ref_offset(fn->raw), ref_flags(fn->raw), ref_offset(fn->raw), ref_flags(fn->raw),
fn->ofs, fn->ofs + fn->size); fn->ofs, fn->ofs + fn->size);
...@@ -703,7 +703,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -703,7 +703,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);
if (ret) { if (ret) {
JFFS2_DBG_READINODE("delete dnode %u-%u.\n", dbg_readinode("delete dnode %u-%u.\n",
fn->ofs, fn->ofs + fn->size); fn->ofs, fn->ofs + fn->size);
jffs2_free_full_dnode(fn); jffs2_free_full_dnode(fn);
} }
...@@ -803,7 +803,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -803,7 +803,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
} }
f->target[je32_to_cpu(latest_node->csize)] = '\0'; f->target[je32_to_cpu(latest_node->csize)] = '\0';
JFFS2_DBG_READINODE("symlink's target '%s' cached\n", f->target); dbg_readinode("symlink's target '%s' cached\n", f->target);
} }
/* fall through... */ /* fall through... */
...@@ -851,7 +851,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, ...@@ -851,7 +851,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
uint32_t ino, struct jffs2_raw_inode *latest_node) uint32_t ino, struct jffs2_raw_inode *latest_node)
{ {
JFFS2_DBG_READINODE("read inode #%u\n", ino); dbg_readinode("read inode #%u\n", ino);
retry_inocache: retry_inocache:
spin_lock(&c->inocache_lock); spin_lock(&c->inocache_lock);
...@@ -870,7 +870,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -870,7 +870,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
/* If it's in either of these states, we need /* If it's in either of these states, we need
to wait for whoever's got it to finish and to wait for whoever's got it to finish and
put it back. */ put it back. */
JFFS2_DBG_READINODE("waiting for ino #%u in state %d\n", ino, f->inocache->state); dbg_readinode("waiting for ino #%u in state %d\n", ino, f->inocache->state);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
goto retry_inocache; goto retry_inocache;
...@@ -897,7 +897,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -897,7 +897,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
JFFS2_ERROR("cannot allocate inocache for root inode\n"); JFFS2_ERROR("cannot allocate inocache for root inode\n");
return -ENOMEM; return -ENOMEM;
} }
JFFS2_DBG_READINODE("creating inocache for root inode\n"); dbg_readinode("creating inocache for root inode\n");
memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); memset(f->inocache, 0, sizeof(struct jffs2_inode_cache));
f->inocache->ino = f->inocache->nlink = 1; f->inocache->ino = f->inocache->nlink = 1;
f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache;
......
...@@ -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.122 2005/09/07 08:34:54 havasi Exp $ * $Id: scan.c,v 1.124 2005/09/21 13:05:22 dedekind Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -429,7 +429,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -429,7 +429,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
noise = 10; noise = 10;
JFFS2_DBG_SUMMARY("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
scan_more: scan_more:
while(ofs < jeb->offset + c->sector_size) { while(ofs < jeb->offset + c->sector_size) {
...@@ -684,7 +684,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -684,7 +684,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (jffs2_sum_active()) { if (jffs2_sum_active()) {
if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) {
JFFS2_DBG_SUMMARY("There is not enough space for " dbg_summary("There is not enough space for "
"summary information, disabling for this jeb!\n"); "summary information, disabling for this jeb!\n");
jffs2_sum_disable_collecting(s); jffs2_sum_disable_collecting(s);
} }
...@@ -920,76 +920,34 @@ void jffs2_rotate_lists(struct jffs2_sb_info *c) ...@@ -920,76 +920,34 @@ void jffs2_rotate_lists(struct jffs2_sb_info *c)
x = count_list(&c->clean_list); x = count_list(&c->clean_list);
if (x) { if (x) {
rotateby = pseudo_random % x; rotateby = pseudo_random % x;
D1(printk(KERN_DEBUG "Rotating clean_list by %d\n", rotateby));
rotate_list((&c->clean_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty clean_list\n"));
} }
x = count_list(&c->very_dirty_list); x = count_list(&c->very_dirty_list);
if (x) { if (x) {
rotateby = pseudo_random % x; rotateby = pseudo_random % x;
D1(printk(KERN_DEBUG "Rotating very_dirty_list by %d\n", rotateby));
rotate_list((&c->very_dirty_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty very_dirty_list\n"));
} }
x = count_list(&c->dirty_list); x = count_list(&c->dirty_list);
if (x) { if (x) {
rotateby = pseudo_random % x; rotateby = pseudo_random % x;
D1(printk(KERN_DEBUG "Rotating dirty_list by %d\n", rotateby));
rotate_list((&c->dirty_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty dirty_list\n"));
} }
x = count_list(&c->erasable_list); x = count_list(&c->erasable_list);
if (x) { if (x) {
rotateby = pseudo_random % x; rotateby = pseudo_random % x;
D1(printk(KERN_DEBUG "Rotating erasable_list by %d\n", rotateby));
rotate_list((&c->erasable_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty erasable_list\n"));
} }
if (c->nr_erasing_blocks) { if (c->nr_erasing_blocks) {
rotateby = pseudo_random % c->nr_erasing_blocks; rotateby = pseudo_random % c->nr_erasing_blocks;
D1(printk(KERN_DEBUG "Rotating erase_pending_list by %d\n", rotateby));
rotate_list((&c->erase_pending_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty erase_pending_list\n"));
} }
if (c->nr_free_blocks) { if (c->nr_free_blocks) {
rotateby = pseudo_random % c->nr_free_blocks; rotateby = pseudo_random % c->nr_free_blocks;
D1(printk(KERN_DEBUG "Rotating free_list by %d\n", rotateby));
rotate_list((&c->free_list), 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 jffs2_eraseblock, list)->offset));
} else {
D1(printk(KERN_DEBUG "Not rotating empty free_list\n"));
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: summary.c,v 1.1 2005/09/07 08:34:54 havasi Exp $ * $Id: summary.c,v 1.3 2005/09/21 14:43:07 dedekind Exp $
* *
*/ */
...@@ -38,17 +38,18 @@ int jffs2_sum_init(struct jffs2_sb_info *c) ...@@ -38,17 +38,18 @@ int jffs2_sum_init(struct jffs2_sb_info *c)
if (!c->summary->sum_buf) { if (!c->summary->sum_buf) {
JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n"); JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
kfree(c->summary);
return -ENOMEM; return -ENOMEM;
} }
JFFS2_DBG_SUMMARY("returned succesfully\n"); dbg_summary("returned succesfully\n");
return 0; return 0;
} }
void jffs2_sum_exit(struct jffs2_sb_info *c) void jffs2_sum_exit(struct jffs2_sb_info *c)
{ {
JFFS2_DBG_SUMMARY("called\n"); dbg_summary("called\n");
jffs2_sum_disable_collecting(c->summary); jffs2_sum_disable_collecting(c->summary);
...@@ -71,13 +72,13 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item) ...@@ -71,13 +72,13 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
case JFFS2_NODETYPE_INODE: case JFFS2_NODETYPE_INODE:
s->sum_size += JFFS2_SUMMARY_INODE_SIZE; s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
s->sum_num++; s->sum_num++;
JFFS2_DBG_SUMMARY("inode (%u) added to summary\n", dbg_summary("inode (%u) added to summary\n",
je32_to_cpu(item->i.inode)); je32_to_cpu(item->i.inode));
break; break;
case JFFS2_NODETYPE_DIRENT: case JFFS2_NODETYPE_DIRENT:
s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize); s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
s->sum_num++; s->sum_num++;
JFFS2_DBG_SUMMARY("dirent (%u) added to summary\n", dbg_summary("dirent (%u) added to summary\n",
je32_to_cpu(item->d.ino)); je32_to_cpu(item->d.ino));
break; break;
default: default:
...@@ -93,7 +94,7 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item) ...@@ -93,7 +94,7 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size) int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
{ {
JFFS2_DBG_SUMMARY("called with %u\n", size); dbg_summary("called with %u\n", size);
s->sum_padded += size; s->sum_padded += size;
return 0; return 0;
} }
...@@ -147,7 +148,7 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s) ...@@ -147,7 +148,7 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s)
union jffs2_sum_mem *temp; union jffs2_sum_mem *temp;
if (!s->sum_list_head) { if (!s->sum_list_head) {
JFFS2_DBG_SUMMARY("already empty\n"); dbg_summary("already empty\n");
} }
while (s->sum_list_head) { while (s->sum_list_head) {
temp = s->sum_list_head; temp = s->sum_list_head;
...@@ -161,14 +162,14 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s) ...@@ -161,14 +162,14 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s)
void jffs2_sum_reset_collected(struct jffs2_summary *s) void jffs2_sum_reset_collected(struct jffs2_summary *s)
{ {
JFFS2_DBG_SUMMARY("called\n"); dbg_summary("called\n");
jffs2_sum_clean_collected(s); jffs2_sum_clean_collected(s);
s->sum_size = 0; s->sum_size = 0;
} }
void jffs2_sum_disable_collecting(struct jffs2_summary *s) void jffs2_sum_disable_collecting(struct jffs2_summary *s)
{ {
JFFS2_DBG_SUMMARY("called\n"); dbg_summary("called\n");
jffs2_sum_clean_collected(s); jffs2_sum_clean_collected(s);
s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
} }
...@@ -182,7 +183,7 @@ int jffs2_sum_is_disabled(struct jffs2_summary *s) ...@@ -182,7 +183,7 @@ int jffs2_sum_is_disabled(struct jffs2_summary *s)
void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s) void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s)
{ {
JFFS2_DBG_SUMMARY("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n", dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
c->summary->sum_size, c->summary->sum_num, c->summary->sum_size, c->summary->sum_num,
s->sum_size, s->sum_num); s->sum_size, s->sum_num);
...@@ -260,16 +261,16 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs, ...@@ -260,16 +261,16 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
} }
case JFFS2_NODETYPE_PADDING: case JFFS2_NODETYPE_PADDING:
JFFS2_DBG_SUMMARY("node PADDING\n"); dbg_summary("node PADDING\n");
c->summary->sum_padded += je32_to_cpu(node->u.totlen); c->summary->sum_padded += je32_to_cpu(node->u.totlen);
break; break;
case JFFS2_NODETYPE_CLEANMARKER: case JFFS2_NODETYPE_CLEANMARKER:
JFFS2_DBG_SUMMARY("node CLEANMARKER\n"); dbg_summary("node CLEANMARKER\n");
break; break;
case JFFS2_NODETYPE_SUMMARY: case JFFS2_NODETYPE_SUMMARY:
JFFS2_DBG_SUMMARY("node SUMMARY\n"); dbg_summary("node SUMMARY\n");
break; break;
default: default:
...@@ -302,7 +303,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -302,7 +303,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
sp = summary->sum; sp = summary->sum;
for (i=0; i<je32_to_cpu(summary->sum_num); i++) { for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
JFFS2_DBG_SUMMARY("processing summary index %d\n", i); dbg_summary("processing summary index %d\n", i);
switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) { switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
case JFFS2_NODETYPE_INODE: { case JFFS2_NODETYPE_INODE: {
...@@ -311,7 +312,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -311,7 +312,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
ino = je32_to_cpu(spi->inode); ino = je32_to_cpu(spi->inode);
JFFS2_DBG_SUMMARY("Inode at 0x%08x\n", dbg_summary("Inode at 0x%08x\n",
jeb->offset + je32_to_cpu(spi->offset)); jeb->offset + je32_to_cpu(spi->offset));
raw = jffs2_alloc_raw_node_ref(); raw = jffs2_alloc_raw_node_ref();
...@@ -353,7 +354,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -353,7 +354,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
struct jffs2_sum_dirent_flash *spd; struct jffs2_sum_dirent_flash *spd;
spd = sp; spd = sp;
JFFS2_DBG_SUMMARY("Dirent at 0x%08x\n", dbg_summary("Dirent at 0x%08x\n",
jeb->offset + je32_to_cpu(spd->offset)); jeb->offset + je32_to_cpu(spd->offset));
fd = jffs2_alloc_full_dirent(spd->nsize+1); fd = jffs2_alloc_full_dirent(spd->nsize+1);
...@@ -434,7 +435,7 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -434,7 +435,7 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
sumsize = c->sector_size - ofs; sumsize = c->sector_size - ofs;
ofs += jeb->offset; ofs += jeb->offset;
JFFS2_DBG_SUMMARY("summary found for 0x%08x at 0x%08x (0x%x bytes)\n", dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
jeb->offset, ofs, sumsize); jeb->offset, ofs, sumsize);
summary = kmalloc(sumsize, GFP_KERNEL); summary = kmalloc(sumsize, GFP_KERNEL);
...@@ -457,40 +458,40 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -457,40 +458,40 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
crc = crc32(0, &crcnode, sizeof(crcnode)-4); crc = crc32(0, &crcnode, sizeof(crcnode)-4);
if (je32_to_cpu(summary->hdr_crc) != crc) { if (je32_to_cpu(summary->hdr_crc) != crc) {
JFFS2_DBG_SUMMARY("Summary node header is corrupt (bad CRC or " dbg_summary("Summary node header is corrupt (bad CRC or "
"no summary at all)\n"); "no summary at all)\n");
goto crc_err; goto crc_err;
} }
if (je32_to_cpu(summary->totlen) != sumsize) { if (je32_to_cpu(summary->totlen) != sumsize) {
JFFS2_DBG_SUMMARY("Summary node is corrupt (wrong erasesize?)\n"); dbg_summary("Summary node is corrupt (wrong erasesize?)\n");
goto crc_err; goto crc_err;
} }
crc = crc32(0, summary, sizeof(struct jffs2_summary_node)-8); crc = crc32(0, summary, sizeof(struct jffs2_summary_node)-8);
if (je32_to_cpu(summary->node_crc) != crc) { if (je32_to_cpu(summary->node_crc) != crc) {
JFFS2_DBG_SUMMARY("Summary node is corrupt (bad CRC)\n"); dbg_summary("Summary node is corrupt (bad CRC)\n");
goto crc_err; goto crc_err;
} }
crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_summary_node)); crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_summary_node));
if (je32_to_cpu(summary->sum_crc) != crc) { if (je32_to_cpu(summary->sum_crc) != crc) {
JFFS2_DBG_SUMMARY("Summary node data is corrupt (bad CRC)\n"); dbg_summary("Summary node data is corrupt (bad CRC)\n");
goto crc_err; goto crc_err;
} }
if ( je32_to_cpu(summary->cln_mkr) ) { if ( je32_to_cpu(summary->cln_mkr) ) {
JFFS2_DBG_SUMMARY("Summary : CLEANMARKER node \n"); dbg_summary("Summary : CLEANMARKER node \n");
if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) { if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
JFFS2_DBG_SUMMARY("CLEANMARKER node has totlen 0x%x != normal 0x%x\n", dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
je32_to_cpu(summary->cln_mkr), c->cleanmarker_size); je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
} else if (jeb->first_node) { } else if (jeb->first_node) {
JFFS2_DBG_SUMMARY("CLEANMARKER node not first node in block " dbg_summary("CLEANMARKER node not first node in block "
"(0x%08x)\n", jeb->offset); "(0x%08x)\n", jeb->offset);
UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
} else { } else {
...@@ -644,7 +645,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -644,7 +645,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
vecs[1].iov_base = c->summary->sum_buf; vecs[1].iov_base = c->summary->sum_buf;
vecs[1].iov_len = datasize; vecs[1].iov_len = datasize;
JFFS2_DBG_SUMMARY("JFFS2: writing out data to flash to pos : 0x%08x\n", dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
jeb->offset + c->sector_size - jeb->free_size); jeb->offset + c->sector_size - jeb->free_size);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -674,7 +675,7 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c) ...@@ -674,7 +675,7 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
int datasize, infosize, padsize, ret; int datasize, infosize, padsize, ret;
struct jffs2_eraseblock *jeb; struct jffs2_eraseblock *jeb;
JFFS2_DBG_SUMMARY("called\n"); dbg_summary("called\n");
jeb = c->nextblock; jeb = c->nextblock;
......
...@@ -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.98 2005/09/07 08:34:55 havasi Exp $ * $Id: wbuf.c,v 1.99 2005/09/21 16:11:04 dedekind Exp $
* *
*/ */
...@@ -33,9 +33,6 @@ static unsigned char *brokenbuf; ...@@ -33,9 +33,6 @@ static unsigned char *brokenbuf;
/* max. erase failures before we mark a block bad */ /* max. erase failures before we mark a block bad */
#define MAX_ERASE_FAILURES 2 #define MAX_ERASE_FAILURES 2
/* two seconds timeout for timed wbuf-flushing */
#define WBUF_FLUSH_TIMEOUT 2 * HZ
struct jffs2_inodirty { struct jffs2_inodirty {
uint32_t ino; uint32_t ino;
struct jffs2_inodirty *next; struct jffs2_inodirty *next;
......
/* $Id: jffs2_fs_sb.h,v 1.53 2005/09/07 08:34:56 havasi Exp $ */ /* $Id: jffs2_fs_sb.h,v 1.54 2005/09/21 13:37:34 dedekind Exp $ */
#ifndef _JFFS2_FS_SB #ifndef _JFFS2_FS_SB
#define _JFFS2_FS_SB #define _JFFS2_FS_SB
...@@ -95,12 +95,13 @@ struct jffs2_sb_info { ...@@ -95,12 +95,13 @@ struct jffs2_sb_info {
to an obsoleted node. I don't like this. Alternatives welcomed. */ to an obsoleted node. I don't like this. Alternatives welcomed. */
struct semaphore erase_free_sem; struct semaphore erase_free_sem;
uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
/* Write-behind buffer for NAND flash */ /* Write-behind buffer for NAND flash */
unsigned char *wbuf; unsigned char *wbuf;
uint32_t wbuf_ofs; uint32_t wbuf_ofs;
uint32_t wbuf_len; uint32_t wbuf_len;
uint32_t wbuf_pagesize;
struct jffs2_inodirty *wbuf_inodes; struct jffs2_inodirty *wbuf_inodes;
struct rw_semaphore wbuf_sem; /* Protects the write buffer */ struct rw_semaphore wbuf_sem; /* Protects the write buffer */
......
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