Commit 9c261b33 authored by Joe Perches's avatar Joe Perches Committed by David Woodhouse

jffs2: Convert most D1/D2 macros to jffs2_dbg

D1 and D2 macros are mostly uses to emit debugging messages.

Convert the logging uses of D1 & D2 to jffs2_dbg(level, fmt, ...)
to be a bit more consistent style with the rest of the kernel.

All jffs2_dbg output is now at KERN_DEBUG where some of
the previous uses were emitted at various KERN_<LEVEL>s.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent bf011f2e
...@@ -47,7 +47,8 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c) ...@@ -47,7 +47,8 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
ret = PTR_ERR(tsk); ret = PTR_ERR(tsk);
} else { } else {
/* Wait for it... */ /* Wait for it... */
D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", tsk->pid)); jffs2_dbg(1, "JFFS2: Garbage collect thread is pid %d\n",
tsk->pid);
wait_for_completion(&c->gc_thread_start); wait_for_completion(&c->gc_thread_start);
ret = tsk->pid; ret = tsk->pid;
} }
...@@ -60,7 +61,7 @@ void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) ...@@ -60,7 +61,7 @@ void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
int wait = 0; int wait = 0;
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
if (c->gc_task) { if (c->gc_task) {
D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid)); jffs2_dbg(1, "jffs2: Killing GC task %d\n", c->gc_task->pid);
send_sig(SIGKILL, c->gc_task, 1); send_sig(SIGKILL, c->gc_task, 1);
wait = 1; wait = 1;
} }
...@@ -90,7 +91,7 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -90,7 +91,7 @@ static int jffs2_garbage_collect_thread(void *_c)
if (!jffs2_thread_should_wake(c)) { if (!jffs2_thread_should_wake(c)) {
set_current_state (TASK_INTERRUPTIBLE); set_current_state (TASK_INTERRUPTIBLE);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); jffs2_dbg(1, "%s(): sleeping...\n", __func__);
schedule(); schedule();
} else } else
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -109,7 +110,7 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -109,7 +110,7 @@ static int jffs2_garbage_collect_thread(void *_c)
schedule_timeout_interruptible(msecs_to_jiffies(50)); schedule_timeout_interruptible(msecs_to_jiffies(50));
if (kthread_should_stop()) { if (kthread_should_stop()) {
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): kthread_stop() called.\n")); jffs2_dbg(1, "%s(): kthread_stop() called\n", __func__);
goto die; goto die;
} }
...@@ -126,26 +127,30 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -126,26 +127,30 @@ static int jffs2_garbage_collect_thread(void *_c)
switch(signr) { switch(signr) {
case SIGSTOP: case SIGSTOP:
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGSTOP received.\n")); jffs2_dbg(1, "%s(): SIGSTOP received\n",
__func__);
set_current_state(TASK_STOPPED); set_current_state(TASK_STOPPED);
schedule(); schedule();
break; break;
case SIGKILL: case SIGKILL:
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGKILL received.\n")); jffs2_dbg(1, "%s(): SIGKILL received\n",
__func__);
goto die; goto die;
case SIGHUP: case SIGHUP:
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGHUP received.\n")); jffs2_dbg(1, "%s(): SIGHUP received\n",
__func__);
break; break;
default: default:
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): signal %ld received\n", signr)); jffs2_dbg(1, "%s(): signal %ld received\n",
__func__, signr);
} }
} }
/* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */
disallow_signal(SIGHUP); disallow_signal(SIGHUP);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): pass\n")); jffs2_dbg(1, "%s(): pass\n", __func__);
if (jffs2_garbage_collect_pass(c) == -ENOSPC) { if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n"); printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n");
goto die; goto die;
......
...@@ -309,7 +309,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) ...@@ -309,7 +309,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp)
comp->stat_compr_new_size=0; comp->stat_compr_new_size=0;
comp->stat_compr_blocks=0; comp->stat_compr_blocks=0;
comp->stat_decompr_blocks=0; comp->stat_decompr_blocks=0;
D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name)); jffs2_dbg(1, "Registering JFFS2 compressor \"%s\"\n", comp->name);
spin_lock(&jffs2_compressor_list_lock); spin_lock(&jffs2_compressor_list_lock);
...@@ -332,9 +332,9 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) ...@@ -332,9 +332,9 @@ int jffs2_register_compressor(struct jffs2_compressor *comp)
int jffs2_unregister_compressor(struct jffs2_compressor *comp) int jffs2_unregister_compressor(struct jffs2_compressor *comp)
{ {
D2(struct jffs2_compressor *this;) D2(struct jffs2_compressor *this);
D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); jffs2_dbg(1, "Unregistering JFFS2 compressor \"%s\"\n", comp->name);
spin_lock(&jffs2_compressor_list_lock); spin_lock(&jffs2_compressor_list_lock);
...@@ -377,17 +377,17 @@ int __init jffs2_compressors_init(void) ...@@ -377,17 +377,17 @@ int __init jffs2_compressors_init(void)
/* Setting default compression mode */ /* Setting default compression mode */
#ifdef CONFIG_JFFS2_CMODE_NONE #ifdef CONFIG_JFFS2_CMODE_NONE
jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) jffs2_dbg(1, "JFFS2: default compression mode: none\n");
#else #else
#ifdef CONFIG_JFFS2_CMODE_SIZE #ifdef CONFIG_JFFS2_CMODE_SIZE
jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) jffs2_dbg(1, "JFFS2: default compression mode: size\n");
#else #else
#ifdef CONFIG_JFFS2_CMODE_FAVOURLZO #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO
jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO;
D1(printk(KERN_INFO "JFFS2: default compression mode: favourlzo\n");) jffs2_dbg(1, "JFFS2: default compression mode: favourlzo\n");
#else #else
D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) jffs2_dbg(1, "JFFS2: default compression mode: priority\n");
#endif #endif
#endif #endif
#endif #endif
......
...@@ -45,13 +45,15 @@ static int __init alloc_workspaces(void) ...@@ -45,13 +45,15 @@ static int __init alloc_workspaces(void)
if (!def_strm.workspace) if (!def_strm.workspace)
return -ENOMEM; return -ENOMEM;
D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL))); jffs2_dbg(1, "Allocated %d bytes for deflate workspace\n",
zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL));
inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); inf_strm.workspace = vmalloc(zlib_inflate_workspacesize());
if (!inf_strm.workspace) { if (!inf_strm.workspace) {
vfree(def_strm.workspace); vfree(def_strm.workspace);
return -ENOMEM; return -ENOMEM;
} }
D1(printk(KERN_DEBUG "Allocated %d bytes for inflate workspace\n", zlib_inflate_workspacesize())); jffs2_dbg(1, "Allocated %d bytes for inflate workspace\n",
zlib_inflate_workspacesize());
return 0; return 0;
} }
...@@ -91,13 +93,14 @@ static int jffs2_zlib_compress(unsigned char *data_in, ...@@ -91,13 +93,14 @@ static int jffs2_zlib_compress(unsigned char *data_in,
while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) {
def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE);
def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out);
D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", jffs2_dbg(1, "calling deflate with avail_in %d, avail_out %d\n",
def_strm.avail_in, def_strm.avail_out)); def_strm.avail_in, def_strm.avail_out);
ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH);
D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", jffs2_dbg(1, "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n",
def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); def_strm.avail_in, def_strm.avail_out,
def_strm.total_in, def_strm.total_out);
if (ret != Z_OK) { if (ret != Z_OK) {
D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); jffs2_dbg(1, "deflate in loop returned %d\n", ret);
zlib_deflateEnd(&def_strm); zlib_deflateEnd(&def_strm);
mutex_unlock(&deflate_mutex); mutex_unlock(&deflate_mutex);
return -1; return -1;
...@@ -109,20 +112,20 @@ static int jffs2_zlib_compress(unsigned char *data_in, ...@@ -109,20 +112,20 @@ static int jffs2_zlib_compress(unsigned char *data_in,
zlib_deflateEnd(&def_strm); zlib_deflateEnd(&def_strm);
if (ret != Z_STREAM_END) { if (ret != Z_STREAM_END) {
D1(printk(KERN_DEBUG "final deflate returned %d\n", ret)); jffs2_dbg(1, "final deflate returned %d\n", ret);
ret = -1; ret = -1;
goto out; goto out;
} }
if (def_strm.total_out >= def_strm.total_in) { if (def_strm.total_out >= def_strm.total_in) {
D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld; failing\n", jffs2_dbg(1, "zlib compressed %ld bytes into %ld; failing\n",
def_strm.total_in, def_strm.total_out)); def_strm.total_in, def_strm.total_out);
ret = -1; ret = -1;
goto out; goto out;
} }
D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld\n", jffs2_dbg(1, "zlib compressed %ld bytes into %ld\n",
def_strm.total_in, def_strm.total_out)); def_strm.total_in, def_strm.total_out);
*dstlen = def_strm.total_out; *dstlen = def_strm.total_out;
*sourcelen = def_strm.total_in; *sourcelen = def_strm.total_in;
...@@ -155,13 +158,13 @@ static int jffs2_zlib_decompress(unsigned char *data_in, ...@@ -155,13 +158,13 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
((data_in[0] & 0x0f) == Z_DEFLATED) && ((data_in[0] & 0x0f) == Z_DEFLATED) &&
!(((data_in[0]<<8) + data_in[1]) % 31)) { !(((data_in[0]<<8) + data_in[1]) % 31)) {
D2(printk(KERN_DEBUG "inflate skipping adler32\n")); jffs2_dbg(2, "inflate skipping adler32\n");
wbits = -((data_in[0] >> 4) + 8); wbits = -((data_in[0] >> 4) + 8);
inf_strm.next_in += 2; inf_strm.next_in += 2;
inf_strm.avail_in -= 2; inf_strm.avail_in -= 2;
} else { } else {
/* Let this remain D1 for now -- it should never happen */ /* Let this remain D1 for now -- it should never happen */
D1(printk(KERN_DEBUG "inflate not skipping adler32\n")); jffs2_dbg(1, "inflate not skipping adler32\n");
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
* superseded by nicer dbg_xxx() macros... * superseded by nicer dbg_xxx() macros...
*/ */
#if CONFIG_JFFS2_FS_DEBUG > 0 #if CONFIG_JFFS2_FS_DEBUG > 0
#define DEBUG
#define D1(x) x #define D1(x) x
#else #else
#define D1(x) #define D1(x)
...@@ -62,6 +63,12 @@ ...@@ -62,6 +63,12 @@
#define D2(x) #define D2(x)
#endif #endif
#define jffs2_dbg(level, fmt, ...) \
do { \
if (CONFIG_JFFS2_FS_DEBUG >= level) \
pr_debug(fmt, ##__VA_ARGS__); \
} while (0)
/* The prefixes of JFFS2 messages */ /* The prefixes of JFFS2 messages */
#define JFFS2_DBG_PREFIX "[JFFS2 DBG]" #define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
#define JFFS2_ERR_PREFIX "JFFS2 error:" #define JFFS2_ERR_PREFIX "JFFS2 error:"
......
...@@ -79,7 +79,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, ...@@ -79,7 +79,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
uint32_t ino = 0; uint32_t ino = 0;
struct inode *inode = NULL; struct inode *inode = NULL;
D1(printk(KERN_DEBUG "jffs2_lookup()\n")); jffs2_dbg(1, "jffs2_lookup()\n");
if (target->d_name.len > JFFS2_MAX_NAME_LEN) if (target->d_name.len > JFFS2_MAX_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
...@@ -119,21 +119,22 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -119,21 +119,22 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
unsigned long offset, curofs; unsigned long offset, curofs;
D1(printk(KERN_DEBUG "jffs2_readdir() for dir_i #%lu\n", filp->f_path.dentry->d_inode->i_ino)); jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n",
filp->f_path.dentry->d_inode->i_ino);
f = JFFS2_INODE_INFO(inode); f = JFFS2_INODE_INFO(inode);
offset = filp->f_pos; offset = filp->f_pos;
if (offset == 0) { if (offset == 0) {
D1(printk(KERN_DEBUG "Dirent 0: \".\", ino #%lu\n", inode->i_ino)); jffs2_dbg(1, "Dirent 0: \".\", ino #%lu\n", inode->i_ino);
if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
goto out; goto out;
offset++; offset++;
} }
if (offset == 1) { if (offset == 1) {
unsigned long pino = parent_ino(filp->f_path.dentry); unsigned long pino = parent_ino(filp->f_path.dentry);
D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", pino)); jffs2_dbg(1, "Dirent 1: \"..\", ino #%lu\n", pino);
if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0)
goto out; goto out;
offset++; offset++;
...@@ -146,16 +147,18 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -146,16 +147,18 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
curofs++; curofs++;
/* First loop: curofs = 2; offset = 2 */ /* First loop: curofs = 2; offset = 2 */
if (curofs < offset) { if (curofs < offset) {
D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n",
fd->name, fd->ino, fd->type, curofs, offset)); fd->name, fd->ino, fd->type, curofs, offset);
continue; continue;
} }
if (!fd->ino) { if (!fd->ino) {
D2(printk(KERN_DEBUG "Skipping deletion dirent \"%s\"\n", fd->name)); jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n",
fd->name);
offset++; offset++;
continue; continue;
} }
D2(printk(KERN_DEBUG "Dirent %ld: \"%s\", ino #%u, type %d\n", offset, fd->name, fd->ino, fd->type)); jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n",
offset, fd->name, fd->ino, fd->type);
if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0)
break; break;
offset++; offset++;
...@@ -184,12 +187,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, ...@@ -184,12 +187,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
c = JFFS2_SB_INFO(dir_i->i_sb); c = JFFS2_SB_INFO(dir_i->i_sb);
D1(printk(KERN_DEBUG "jffs2_create()\n")); jffs2_dbg(1, "%s()\n", __func__);
inode = jffs2_new_inode(dir_i, mode, ri); inode = jffs2_new_inode(dir_i, mode, ri);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); jffs2_dbg(1, "jffs2_new_inode() failed\n");
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
return PTR_ERR(inode); return PTR_ERR(inode);
} }
...@@ -217,9 +220,9 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, ...@@ -217,9 +220,9 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", jffs2_dbg(1, "%s(): Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n",
inode->i_ino, inode->i_mode, inode->i_nlink, __func__, inode->i_ino, inode->i_mode, inode->i_nlink,
f->inocache->pino_nlink, inode->i_mapping->nrpages)); f->inocache->pino_nlink, inode->i_mapping->nrpages);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_new_inode(inode); unlock_new_inode(inode);
...@@ -369,7 +372,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -369,7 +372,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
goto fail; goto fail;
} }
D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target)); jffs2_dbg(1, "%s(): symlink's target '%s' cached\n",
__func__, (char *)f->target);
/* No data here. Only a metadata node, which will be /* No data here. Only a metadata node, which will be
obsoleted by the first data write obsoleted by the first data write
......
...@@ -46,8 +46,9 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, ...@@ -46,8 +46,9 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
#else /* Linux */ #else /* Linux */
struct erase_info *instr; struct erase_info *instr;
D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n", jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n",
jeb->offset, jeb->offset, jeb->offset + c->sector_size)); __func__,
jeb->offset, jeb->offset, jeb->offset + c->sector_size);
instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL);
if (!instr) { if (!instr) {
printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
...@@ -84,7 +85,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, ...@@ -84,7 +85,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
if (ret == -ENOMEM || ret == -EAGAIN) { if (ret == -ENOMEM || ret == -EAGAIN) {
/* Erase failed immediately. Refile it on the list */ /* Erase failed immediately. Refile it on the list */
D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret)); jffs2_dbg(1, "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n",
jeb->offset, ret);
mutex_lock(&c->erase_free_sem); mutex_lock(&c->erase_free_sem);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
list_move(&jeb->list, &c->erase_pending_list); list_move(&jeb->list, &c->erase_pending_list);
...@@ -125,13 +127,14 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) ...@@ -125,13 +127,14 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count)
work_done++; work_done++;
if (!--count) { if (!--count) {
D1(printk(KERN_DEBUG "Count reached. jffs2_erase_pending_blocks leaving\n")); jffs2_dbg(1, "Count reached. jffs2_erase_pending_blocks leaving\n");
goto done; goto done;
} }
} else if (!list_empty(&c->erase_pending_list)) { } else if (!list_empty(&c->erase_pending_list)) {
jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list);
D1(printk(KERN_DEBUG "Starting erase of pending block 0x%08x\n", jeb->offset)); jffs2_dbg(1, "Starting erase of pending block 0x%08x\n",
jeb->offset);
list_del(&jeb->list); list_del(&jeb->list);
c->erasing_size += c->sector_size; c->erasing_size += c->sector_size;
c->wasted_size -= jeb->wasted_size; c->wasted_size -= jeb->wasted_size;
...@@ -159,13 +162,13 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) ...@@ -159,13 +162,13 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count)
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->erase_free_sem); mutex_unlock(&c->erase_free_sem);
done: done:
D1(printk(KERN_DEBUG "jffs2_erase_pending_blocks completed\n")); jffs2_dbg(1, "jffs2_erase_pending_blocks completed\n");
return work_done; return work_done;
} }
static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{ {
D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset)); jffs2_dbg(1, "Erase completed successfully at 0x%08x\n", jeb->offset);
mutex_lock(&c->erase_free_sem); mutex_lock(&c->erase_free_sem);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
list_move_tail(&jeb->list, &c->erase_complete_list); list_move_tail(&jeb->list, &c->erase_complete_list);
...@@ -269,8 +272,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, ...@@ -269,8 +272,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
return; return;
} }
D1(printk(KERN_DEBUG "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", jffs2_dbg(1, "Removed nodes in range 0x%08x-0x%08x from ino #%u\n",
jeb->offset, jeb->offset + c->sector_size, ic->ino)); jeb->offset, jeb->offset + c->sector_size, ic->ino);
D2({ D2({
int i=0; int i=0;
...@@ -310,7 +313,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, ...@@ -310,7 +313,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{ {
struct jffs2_raw_node_ref *block, *ref; struct jffs2_raw_node_ref *block, *ref;
D1(printk(KERN_DEBUG "Freeing all node refs for eraseblock offset 0x%08x\n", jeb->offset)); jffs2_dbg(1, "Freeing all node refs for eraseblock offset 0x%08x\n",
jeb->offset);
block = ref = jeb->first_node; block = ref = jeb->first_node;
...@@ -342,12 +346,13 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl ...@@ -342,12 +346,13 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
&ebuf, NULL); &ebuf, NULL);
if (ret != -EOPNOTSUPP) { if (ret != -EOPNOTSUPP) {
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); jffs2_dbg(1, "MTD point failed %d\n", ret);
goto do_flash_read; goto do_flash_read;
} }
if (retlen < c->sector_size) { if (retlen < c->sector_size) {
/* Don't muck about if it won't let us point to the whole erase sector */ /* Don't muck about if it won't let us point to the whole erase sector */
D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n",
retlen);
mtd_unpoint(c->mtd, jeb->offset, retlen); mtd_unpoint(c->mtd, jeb->offset, retlen);
goto do_flash_read; goto do_flash_read;
} }
...@@ -372,7 +377,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl ...@@ -372,7 +377,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
return -EAGAIN; return -EAGAIN;
} }
D1(printk(KERN_DEBUG "Verifying erase at 0x%08x\n", jeb->offset)); jffs2_dbg(1, "Verifying erase at 0x%08x\n", jeb->offset);
for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) {
uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs);
...@@ -422,7 +427,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb ...@@ -422,7 +427,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
} }
/* Write the erase complete marker */ /* Write the erase complete marker */
D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); jffs2_dbg(1, "Writing erased marker to block at 0x%08x\n", jeb->offset);
bad_offset = jeb->offset; bad_offset = jeb->offset;
/* Cleanmarker in oob area or no cleanmarker at all ? */ /* Cleanmarker in oob area or no cleanmarker at all ? */
......
...@@ -85,7 +85,8 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) ...@@ -85,7 +85,8 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
unsigned char *pg_buf; unsigned char *pg_buf;
int ret; int ret;
D2(printk(KERN_DEBUG "jffs2_do_readpage_nolock(): ino #%lu, page at offset 0x%lx\n", inode->i_ino, pg->index << PAGE_CACHE_SHIFT)); jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
__func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT);
BUG_ON(!PageLocked(pg)); BUG_ON(!PageLocked(pg));
...@@ -105,7 +106,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) ...@@ -105,7 +106,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
flush_dcache_page(pg); flush_dcache_page(pg);
kunmap(pg); kunmap(pg);
D2(printk(KERN_DEBUG "readpage finished\n")); jffs2_dbg(2, "readpage finished\n");
return ret; return ret;
} }
...@@ -144,7 +145,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, ...@@ -144,7 +145,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
return -ENOMEM; return -ENOMEM;
*pagep = pg; *pagep = pg;
D1(printk(KERN_DEBUG "jffs2_write_begin()\n")); jffs2_dbg(1, "%s()\n", __func__);
if (pageofs > inode->i_size) { if (pageofs > inode->i_size) {
/* Make new hole frag from old EOF to new page */ /* Make new hole frag from old EOF to new page */
...@@ -153,8 +154,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, ...@@ -153,8 +154,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
uint32_t alloc_len; uint32_t alloc_len;
D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
(unsigned int)inode->i_size, pageofs)); (unsigned int)inode->i_size, pageofs);
ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
...@@ -198,7 +199,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, ...@@ -198,7 +199,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
f->metadata = NULL; f->metadata = NULL;
} }
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n", ret)); jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n",
ret);
jffs2_mark_node_obsolete(c, fn->raw); jffs2_mark_node_obsolete(c, fn->raw);
jffs2_free_full_dnode(fn); jffs2_free_full_dnode(fn);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
...@@ -222,7 +224,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, ...@@ -222,7 +224,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
if (ret) if (ret)
goto out_page; goto out_page;
} }
D1(printk(KERN_DEBUG "end write_begin(). pg->flags %lx\n", pg->flags)); jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
return ret; return ret;
out_page: out_page:
...@@ -248,8 +250,9 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, ...@@ -248,8 +250,9 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
int ret = 0; int ret = 0;
uint32_t writtenlen = 0; uint32_t writtenlen = 0;
D1(printk(KERN_DEBUG "jffs2_write_end(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n", jffs2_dbg(1, "%s(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n",
inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end, pg->flags)); __func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT,
start, end, pg->flags);
/* We need to avoid deadlock with page_cache_read() in /* We need to avoid deadlock with page_cache_read() in
jffs2_garbage_collect_pass(). So the page must be jffs2_garbage_collect_pass(). So the page must be
...@@ -268,7 +271,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, ...@@ -268,7 +271,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
ri = jffs2_alloc_raw_inode(); ri = jffs2_alloc_raw_inode();
if (!ri) { if (!ri) {
D1(printk(KERN_DEBUG "jffs2_write_end(): Allocation of raw inode failed\n")); jffs2_dbg(1, "%s(): Allocation of raw inode failed\n",
__func__);
unlock_page(pg); unlock_page(pg);
page_cache_release(pg); page_cache_release(pg);
return -ENOMEM; return -ENOMEM;
...@@ -315,13 +319,14 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, ...@@ -315,13 +319,14 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
/* generic_file_write has written more to the page cache than we've /* generic_file_write has written more to the page cache than we've
actually written to the medium. Mark the page !Uptodate so that actually written to the medium. Mark the page !Uptodate so that
it gets reread */ it gets reread */
D1(printk(KERN_DEBUG "jffs2_write_end(): Not all bytes written. Marking page !uptodate\n")); jffs2_dbg(1, "%s(): Not all bytes written. Marking page !uptodate\n",
__func__);
SetPageError(pg); SetPageError(pg);
ClearPageUptodate(pg); ClearPageUptodate(pg);
} }
D1(printk(KERN_DEBUG "jffs2_write_end() returning %d\n", jffs2_dbg(1, "%s() returning %d\n",
writtenlen > 0 ? writtenlen : ret)); __func__, writtenlen > 0 ? writtenlen : ret);
unlock_page(pg); unlock_page(pg);
page_cache_release(pg); page_cache_release(pg);
return writtenlen > 0 ? writtenlen : ret; return writtenlen > 0 ? writtenlen : ret;
......
...@@ -39,7 +39,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -39,7 +39,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
int ret; int ret;
int alloc_type = ALLOC_NORMAL; int alloc_type = ALLOC_NORMAL;
D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); jffs2_dbg(1, "%s(): ino #%lu\n", __func__, inode->i_ino);
/* Special cases - we don't want more than one data node /* Special cases - we don't want more than one data node
for these types on the medium at any time. So setattr for these types on the medium at any time. So setattr
...@@ -50,7 +50,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -50,7 +50,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
/* For these, we don't actually need to read the old node */ /* For these, we don't actually need to read the old node */
mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); mdatalen = jffs2_encode_dev(&dev, inode->i_rdev);
mdata = (char *)&dev; mdata = (char *)&dev;
D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n",
__func__, mdatalen);
} else if (S_ISLNK(inode->i_mode)) { } else if (S_ISLNK(inode->i_mode)) {
mutex_lock(&f->sem); mutex_lock(&f->sem);
mdatalen = f->metadata->size; mdatalen = f->metadata->size;
...@@ -66,7 +67,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -66,7 +67,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
return ret; return ret;
} }
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); jffs2_dbg(1, "%s(): Writing %d bytes of symlink target\n",
__func__, mdatalen);
} }
ri = jffs2_alloc_raw_inode(); ri = jffs2_alloc_raw_inode();
...@@ -233,7 +235,8 @@ void jffs2_evict_inode (struct inode *inode) ...@@ -233,7 +235,8 @@ void jffs2_evict_inode (struct inode *inode)
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
D1(printk(KERN_DEBUG "jffs2_evict_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
__func__, inode->i_ino, inode->i_mode);
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode); end_writeback(inode);
jffs2_do_clear_inode(c, f); jffs2_do_clear_inode(c, f);
...@@ -249,7 +252,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) ...@@ -249,7 +252,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
dev_t rdev = 0; dev_t rdev = 0;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino)); jffs2_dbg(1, "%s(): ino == %lu\n", __func__, ino);
inode = iget_locked(sb, ino); inode = iget_locked(sb, ino);
if (!inode) if (!inode)
...@@ -320,7 +323,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) ...@@ -320,7 +323,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size);
goto error_io; goto error_io;
} }
D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); jffs2_dbg(1, "Reading device numbers from flash\n");
ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size);
if (ret < 0) { if (ret < 0) {
/* Eep */ /* Eep */
...@@ -344,7 +347,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) ...@@ -344,7 +347,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); jffs2_dbg(1, "jffs2_read_inode() returning\n");
unlock_new_inode(inode); unlock_new_inode(inode);
return inode; return inode;
...@@ -362,11 +365,13 @@ void jffs2_dirty_inode(struct inode *inode, int flags) ...@@ -362,11 +365,13 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
struct iattr iattr; struct iattr iattr;
if (!(inode->i_state & I_DIRTY_DATASYNC)) { if (!(inode->i_state & I_DIRTY_DATASYNC)) {
D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino)); jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n",
__func__, inode->i_ino);
return; return;
} }
D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino)); jffs2_dbg(1, "%s(): calling setattr() for ino #%lu\n",
__func__, inode->i_ino);
iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
iattr.ia_mode = inode->i_mode; iattr.ia_mode = inode->i_mode;
...@@ -414,7 +419,8 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r ...@@ -414,7 +419,8 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
struct jffs2_inode_info *f; struct jffs2_inode_info *f;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); jffs2_dbg(1, "%s(): dir_i %ld, mode 0x%x\n",
__func__, dir_i->i_ino, mode);
c = JFFS2_SB_INFO(sb); c = JFFS2_SB_INFO(sb);
...@@ -550,17 +556,17 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) ...@@ -550,17 +556,17 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
if ((ret = jffs2_do_mount_fs(c))) if ((ret = jffs2_do_mount_fs(c)))
goto out_inohash; goto out_inohash;
D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); jffs2_dbg(1, "%s(): Getting root inode\n", __func__);
root_i = jffs2_iget(sb, 1); root_i = jffs2_iget(sb, 1);
if (IS_ERR(root_i)) { if (IS_ERR(root_i)) {
D1(printk(KERN_WARNING "get root inode failed\n")); jffs2_dbg(1, "get root inode failed\n");
ret = PTR_ERR(root_i); ret = PTR_ERR(root_i);
goto out_root; goto out_root;
} }
ret = -ENOMEM; ret = -ENOMEM;
D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); jffs2_dbg(1, "%s(): d_alloc_root()\n", __func__);
sb->s_root = d_alloc_root(root_i); sb->s_root = d_alloc_root(root_i);
if (!sb->s_root) if (!sb->s_root)
goto out_root_i; goto out_root_i;
...@@ -620,20 +626,21 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, ...@@ -620,20 +626,21 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
*/ */
inode = ilookup(OFNI_BS_2SFFJ(c), inum); inode = ilookup(OFNI_BS_2SFFJ(c), inum);
if (!inode) { if (!inode) {
D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n", jffs2_dbg(1, "ilookup() failed for ino #%u; inode is probably deleted.\n",
inum)); inum);
spin_lock(&c->inocache_lock); spin_lock(&c->inocache_lock);
ic = jffs2_get_ino_cache(c, inum); ic = jffs2_get_ino_cache(c, inum);
if (!ic) { if (!ic) {
D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum)); jffs2_dbg(1, "Inode cache for ino #%u is gone\n",
inum);
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
return NULL; return NULL;
} }
if (ic->state != INO_STATE_CHECKEDABSENT) { if (ic->state != INO_STATE_CHECKEDABSENT) {
/* Wait for progress. Don't just loop */ /* Wait for progress. Don't just loop */
D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n", jffs2_dbg(1, "Waiting for ino #%u in state %d\n",
ic->ino, ic->state)); ic->ino, ic->state);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
} else { } else {
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
......
...@@ -51,44 +51,44 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) ...@@ -51,44 +51,44 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c)
number of free blocks is low. */ number of free blocks is low. */
again: again:
if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { 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")); jffs2_dbg(1, "Picking block from bad_used_list to GC next\n");
nextlist = &c->bad_used_list; nextlist = &c->bad_used_list;
} else if (n < 50 && !list_empty(&c->erasable_list)) { } else if (n < 50 && !list_empty(&c->erasable_list)) {
/* Note that most of them will have gone directly to be erased. /* Note that most of them will have gone directly to be erased.
So don't favour the erasable_list _too_ much. */ So don't favour the erasable_list _too_ much. */
D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); jffs2_dbg(1, "Picking block from erasable_list to GC next\n");
nextlist = &c->erasable_list; nextlist = &c->erasable_list;
} else if (n < 110 && !list_empty(&c->very_dirty_list)) { } else if (n < 110 && !list_empty(&c->very_dirty_list)) {
/* Most of the time, pick one off the 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")); jffs2_dbg(1, "Picking block from very_dirty_list to GC next\n");
nextlist = &c->very_dirty_list; nextlist = &c->very_dirty_list;
} else if (n < 126 && !list_empty(&c->dirty_list)) { } else if (n < 126 && !list_empty(&c->dirty_list)) {
D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next\n")); jffs2_dbg(1, "Picking block from dirty_list to GC next\n");
nextlist = &c->dirty_list; nextlist = &c->dirty_list;
} else if (!list_empty(&c->clean_list)) { } else if (!list_empty(&c->clean_list)) {
D1(printk(KERN_DEBUG "Picking block from clean_list to GC next\n")); jffs2_dbg(1, "Picking block from clean_list to GC next\n");
nextlist = &c->clean_list; nextlist = &c->clean_list;
} else if (!list_empty(&c->dirty_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")); jffs2_dbg(1, "Picking block from dirty_list to GC next (clean_list was empty)\n");
nextlist = &c->dirty_list; nextlist = &c->dirty_list;
} else if (!list_empty(&c->very_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")); jffs2_dbg(1, "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n");
nextlist = &c->very_dirty_list; nextlist = &c->very_dirty_list;
} else if (!list_empty(&c->erasable_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")); jffs2_dbg(1, "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n");
nextlist = &c->erasable_list; nextlist = &c->erasable_list;
} else if (!list_empty(&c->erasable_pending_wbuf_list)) { } else if (!list_empty(&c->erasable_pending_wbuf_list)) {
/* There are blocks are wating for the wbuf sync */ /* There are blocks are wating for the wbuf sync */
D1(printk(KERN_DEBUG "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n")); jffs2_dbg(1, "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n");
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
jffs2_flush_wbuf_pad(c); jffs2_flush_wbuf_pad(c);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
goto again; goto again;
} else { } else {
/* Eep. All were empty */ /* Eep. All were empty */
D1(printk(KERN_NOTICE "jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n")); jffs2_dbg(1, "jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n");
return NULL; return NULL;
} }
...@@ -103,7 +103,8 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) ...@@ -103,7 +103,8 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c)
/* Have we accidentally picked a clean block with wasted space ? */ /* Have we accidentally picked a clean block with wasted space ? */
if (ret->wasted_size) { if (ret->wasted_size) {
D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); jffs2_dbg(1, "Converting wasted_size %08x to dirty_size\n",
ret->wasted_size);
ret->dirty_size += ret->wasted_size; ret->dirty_size += ret->wasted_size;
c->wasted_size -= ret->wasted_size; c->wasted_size -= ret->wasted_size;
c->dirty_size += ret->wasted_size; c->dirty_size += ret->wasted_size;
...@@ -163,8 +164,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -163,8 +164,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
} }
if (!ic->pino_nlink) { if (!ic->pino_nlink) {
D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink/pino zero\n", jffs2_dbg(1, "Skipping check of ino #%d with nlink/pino zero\n",
ic->ino)); ic->ino);
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
jffs2_xattr_delete_inode(c, ic); jffs2_xattr_delete_inode(c, ic);
continue; continue;
...@@ -172,7 +173,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -172,7 +173,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
switch(ic->state) { switch(ic->state) {
case INO_STATE_CHECKEDABSENT: case INO_STATE_CHECKEDABSENT:
case INO_STATE_PRESENT: case INO_STATE_PRESENT:
D1(printk(KERN_DEBUG "Skipping ino #%u already checked\n", ic->ino)); jffs2_dbg(1, "Skipping ino #%u already checked\n",
ic->ino);
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
continue; continue;
...@@ -186,7 +188,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -186,7 +188,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
/* We need to wait for it to finish, lest we move on /* We need to wait for it to finish, lest we move on
and trigger the BUG() above while we haven't yet and trigger the BUG() above while we haven't yet
finished checking all its nodes */ finished checking all its nodes */
D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); jffs2_dbg(1, "Waiting for ino #%u to finish reading\n",
ic->ino);
/* We need to come back again for the _same_ inode. We've /* We need to come back again for the _same_ inode. We've
made no progress in this case, but that should be OK */ made no progress in this case, but that should be OK */
c->checked_ino--; c->checked_ino--;
...@@ -204,7 +207,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -204,7 +207,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
ic->state = INO_STATE_CHECKING; ic->state = INO_STATE_CHECKING;
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino)); jffs2_dbg(1, "%s(): triggering inode scan of ino#%u\n",
__func__, ic->ino);
ret = jffs2_do_crccheck_inode(c, ic); ret = jffs2_do_crccheck_inode(c, ic);
if (ret) if (ret)
...@@ -220,11 +224,11 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -220,11 +224,11 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
!list_empty(&c->erase_pending_list)) { !list_empty(&c->erase_pending_list)) {
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() erasing pending blocks\n")); jffs2_dbg(1, "%s(): erasing pending blocks\n", __func__);
if (jffs2_erase_pending_blocks(c, 1)) if (jffs2_erase_pending_blocks(c, 1))
return 0; return 0;
D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n")); jffs2_dbg(1, "No progress from erasing block; doing GC anyway\n");
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
mutex_lock(&c->alloc_sem); mutex_lock(&c->alloc_sem);
} }
...@@ -242,13 +246,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -242,13 +246,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
return -EAGAIN; return -EAGAIN;
} }
D1(printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); jffs2_dbg(1, "jffs2: Couldn't find erase block to garbage collect!\n");
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
return -EIO; 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)); jffs2_dbg(1, "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) 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)); 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));
...@@ -261,7 +266,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -261,7 +266,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
gcblock_dirty = jeb->dirty_size; gcblock_dirty = jeb->dirty_size;
while(ref_obsolete(raw)) { while(ref_obsolete(raw)) {
D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); jffs2_dbg(1, "Node at 0x%08x is obsolete... skipping\n",
ref_offset(raw));
raw = ref_next(raw); raw = ref_next(raw);
if (unlikely(!raw)) { if (unlikely(!raw)) {
printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n");
...@@ -275,7 +281,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -275,7 +281,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
} }
jeb->gc_node = raw; jeb->gc_node = raw;
D1(printk(KERN_DEBUG "Going to garbage collect node at 0x%08x\n", ref_offset(raw))); jffs2_dbg(1, "Going to garbage collect node at 0x%08x\n",
ref_offset(raw));
if (!raw->next_in_ino) { if (!raw->next_in_ino) {
/* Inode-less node. Clean marker, snapshot or something like that */ /* Inode-less node. Clean marker, snapshot or something like that */
...@@ -316,7 +323,9 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -316,7 +323,9 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_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)); jffs2_dbg(1, "%s(): collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n",
__func__, jeb->offset, ref_offset(raw), ref_flags(raw),
ic->ino);
/* Three possibilities: /* Three possibilities:
1. Inode is already in-core. We must iget it and do proper 1. Inode is already in-core. We must iget it and do proper
...@@ -336,8 +345,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -336,8 +345,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
if (ref_flags(raw) == REF_PRISTINE) if (ref_flags(raw) == REF_PRISTINE)
ic->state = INO_STATE_GC; ic->state = INO_STATE_GC;
else { else {
D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", jffs2_dbg(1, "Ino #%u is absent but node not REF_PRISTINE. Reading.\n",
ic->ino)); ic->ino);
} }
break; break;
...@@ -367,8 +376,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -367,8 +376,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
drop the alloc_sem before sleeping. */ drop the alloc_sem before sleeping. */
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", jffs2_dbg(1, "%s(): waiting for ino #%u in state %d\n",
ic->ino, ic->state)); __func__, ic->ino, ic->state);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
/* And because we dropped the alloc_sem we must start again from the /* And because we dropped the alloc_sem we must start again from the
beginning. Ponder chance of livelock here -- we're returning success beginning. Ponder chance of livelock here -- we're returning success
...@@ -445,7 +454,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -445,7 +454,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
eraseit: eraseit:
if (c->gcblock && !c->gcblock->used_size) { 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)); jffs2_dbg(1, "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n",
c->gcblock->offset);
/* We're GC'ing an empty block? */ /* We're GC'ing an empty block? */
list_add_tail(&c->gcblock->list, &c->erase_pending_list); list_add_tail(&c->gcblock->list, &c->erase_pending_list);
c->gcblock = NULL; c->gcblock = NULL;
...@@ -475,12 +485,12 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era ...@@ -475,12 +485,12 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era
if (c->gcblock != jeb) { if (c->gcblock != jeb) {
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "GC block is no longer gcblock. Restart\n")); jffs2_dbg(1, "GC block is no longer gcblock. Restart\n");
goto upnout; goto upnout;
} }
if (ref_obsolete(raw)) { if (ref_obsolete(raw)) {
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "node to be GC'd was obsoleted in the meantime.\n")); jffs2_dbg(1, "node to be GC'd was obsoleted in the meantime.\n");
/* They'll call again */ /* They'll call again */
goto upnout; goto upnout;
} }
...@@ -562,7 +572,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -562,7 +572,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
uint32_t crc, rawlen; uint32_t crc, rawlen;
int retried = 0; int retried = 0;
D1(printk(KERN_DEBUG "Going to GC REF_PRISTINE node at 0x%08x\n", ref_offset(raw))); jffs2_dbg(1, "Going to GC REF_PRISTINE node at 0x%08x\n",
ref_offset(raw));
alloclen = rawlen = ref_totlen(c, c->gcblock, raw); alloclen = rawlen = ref_totlen(c, c->gcblock, raw);
...@@ -671,7 +682,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -671,7 +682,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
retried = 1; retried = 1;
D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); jffs2_dbg(1, "Retrying failed write of REF_PRISTINE node.\n");
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
...@@ -681,14 +692,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -681,14 +692,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
it is only an upper estimation */ it is only an upper estimation */
if (!ret) { if (!ret) {
D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n",
phys_ofs);
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
goto retry; goto retry;
} }
D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n",
ret);
} }
if (!ret) if (!ret)
...@@ -698,7 +711,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -698,7 +711,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic);
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); jffs2_dbg(1, "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n",
ref_offset(raw));
out_node: out_node:
kfree(node); kfree(node);
...@@ -725,7 +739,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ ...@@ -725,7 +739,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
/* For these, we don't actually need to read the old node */ /* For these, we don't actually need to read the old node */
mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f));
mdata = (char *)&dev; mdata = (char *)&dev;
D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen)); jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n",
__func__, mdatalen);
} else if (S_ISLNK(JFFS2_F_I_MODE(f))) { } else if (S_ISLNK(JFFS2_F_I_MODE(f))) {
mdatalen = fn->size; mdatalen = fn->size;
mdata = kmalloc(fn->size, GFP_KERNEL); mdata = kmalloc(fn->size, GFP_KERNEL);
...@@ -739,7 +754,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ ...@@ -739,7 +754,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
kfree(mdata); kfree(mdata);
return ret; return ret;
} }
D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); jffs2_dbg(1, "%s(): Writing %d bites of symlink target\n",
__func__, mdatalen);
} }
...@@ -887,7 +903,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct ...@@ -887,7 +903,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset))
continue; continue;
D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw))); jffs2_dbg(1, "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 /* This is an obsolete node belonging to the same directory, and it's of the right
length. We need to take a closer look...*/ length. We need to take a closer look...*/
...@@ -923,8 +940,9 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct ...@@ -923,8 +940,9 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
a new deletion dirent to replace it */ a new deletion dirent to replace it */
mutex_unlock(&c->erase_free_sem); mutex_unlock(&c->erase_free_sem);
D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", jffs2_dbg(1, "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))); ref_offset(fd->raw), fd->name,
ref_offset(raw), je32_to_cpu(rd->ino));
kfree(rd); kfree(rd);
return jffs2_garbage_collect_dirent(c, jeb, f, fd); return jffs2_garbage_collect_dirent(c, jeb, f, fd);
...@@ -964,8 +982,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -964,8 +982,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
uint32_t alloclen, ilen; uint32_t alloclen, ilen;
int ret; int ret;
D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", jffs2_dbg(1, "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
f->inocache->ino, start, end)); f->inocache->ino, start, end);
memset(&ri, 0, sizeof(ri)); memset(&ri, 0, sizeof(ri));
...@@ -1117,8 +1135,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1117,8 +1135,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
memset(&ri, 0, sizeof(ri)); memset(&ri, 0, sizeof(ri));
D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", jffs2_dbg(1, "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",
f->inocache->ino, start, end)); f->inocache->ino, start, end);
orig_end = end; orig_end = end;
orig_start = start; orig_start = start;
...@@ -1149,15 +1167,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1149,15 +1167,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
/* If the previous frag doesn't even reach the beginning, there's /* If the previous frag doesn't even reach the beginning, there's
excessive fragmentation. Just merge. */ excessive fragmentation. Just merge. */
if (frag->ofs > min) { if (frag->ofs > min) {
D1(printk(KERN_DEBUG "Expanding down to cover partial frag (0x%x-0x%x)\n", jffs2_dbg(1, "Expanding down to cover partial frag (0x%x-0x%x)\n",
frag->ofs, frag->ofs+frag->size)); frag->ofs, frag->ofs+frag->size);
start = frag->ofs; start = frag->ofs;
continue; continue;
} }
/* OK. This frag holds the first byte of the page. */ /* OK. This frag holds the first byte of the page. */
if (!frag->node || !frag->node->raw) { if (!frag->node || !frag->node->raw) {
D1(printk(KERN_DEBUG "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", jffs2_dbg(1, "First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
frag->ofs, frag->ofs+frag->size)); frag->ofs, frag->ofs+frag->size);
break; break;
} else { } else {
...@@ -1171,19 +1189,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1171,19 +1189,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
jeb = &c->blocks[raw->flash_offset / c->sector_size]; jeb = &c->blocks[raw->flash_offset / c->sector_size];
if (jeb == c->gcblock) { if (jeb == c->gcblock) {
D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n",
frag->ofs, frag->ofs+frag->size, ref_offset(raw))); frag->ofs,
frag->ofs + frag->size,
ref_offset(raw));
start = frag->ofs; start = frag->ofs;
break; break;
} }
if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { 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", jffs2_dbg(1, "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n",
frag->ofs, frag->ofs+frag->size, jeb->offset)); frag->ofs,
frag->ofs + frag->size,
jeb->offset);
break; break;
} }
D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n",
frag->ofs, frag->ofs+frag->size, jeb->offset)); frag->ofs,
frag->ofs + frag->size,
jeb->offset);
start = frag->ofs; start = frag->ofs;
break; break;
} }
...@@ -1199,15 +1223,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1199,15 +1223,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
/* If the previous frag doesn't even reach the beginning, there's lots /* If the previous frag doesn't even reach the beginning, there's lots
of fragmentation. Just merge. */ of fragmentation. Just merge. */
if (frag->ofs+frag->size < max) { if (frag->ofs+frag->size < max) {
D1(printk(KERN_DEBUG "Expanding up to cover partial frag (0x%x-0x%x)\n", jffs2_dbg(1, "Expanding up to cover partial frag (0x%x-0x%x)\n",
frag->ofs, frag->ofs+frag->size)); frag->ofs, frag->ofs+frag->size);
end = frag->ofs + frag->size; end = frag->ofs + frag->size;
continue; continue;
} }
if (!frag->node || !frag->node->raw) { if (!frag->node || !frag->node->raw) {
D1(printk(KERN_DEBUG "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", jffs2_dbg(1, "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n",
frag->ofs, frag->ofs+frag->size)); frag->ofs, frag->ofs+frag->size);
break; break;
} else { } else {
...@@ -1221,25 +1245,31 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1221,25 +1245,31 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
jeb = &c->blocks[raw->flash_offset / c->sector_size]; jeb = &c->blocks[raw->flash_offset / c->sector_size];
if (jeb == c->gcblock) { if (jeb == c->gcblock) {
D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n",
frag->ofs, frag->ofs+frag->size, ref_offset(raw))); frag->ofs,
frag->ofs + frag->size,
ref_offset(raw));
end = frag->ofs + frag->size; end = frag->ofs + frag->size;
break; break;
} }
if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { 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", jffs2_dbg(1, "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n",
frag->ofs, frag->ofs+frag->size, jeb->offset)); frag->ofs,
frag->ofs + frag->size,
jeb->offset);
break; break;
} }
D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n",
frag->ofs, frag->ofs+frag->size, jeb->offset)); frag->ofs,
frag->ofs + frag->size,
jeb->offset);
end = frag->ofs + frag->size; end = frag->ofs + frag->size;
break; break;
} }
} }
D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", jffs2_dbg(1, "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n",
orig_start, orig_end, start, end)); orig_start, orig_end, start, end);
D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size));
BUG_ON(end < orig_end); BUG_ON(end < orig_end);
......
...@@ -46,10 +46,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -46,10 +46,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
/* align it */ /* align it */
minsize = PAD(minsize); minsize = PAD(minsize);
D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize);
mutex_lock(&c->alloc_sem); mutex_lock(&c->alloc_sem);
D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); jffs2_dbg(1, "%s(): alloc sem got\n", __func__);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
...@@ -73,11 +73,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -73,11 +73,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size; dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size;
if (dirty < c->nospc_dirty_size) { if (dirty < c->nospc_dirty_size) {
if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) {
D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on dirty space to GC, but it's a deletion. Allowing...\n")); jffs2_dbg(1, "%s(): Low on dirty space to GC, but it's a deletion. Allowing...\n",
__func__);
break; break;
} }
D1(printk(KERN_DEBUG "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n", jffs2_dbg(1, "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n",
dirty, c->unchecked_size, c->sector_size)); dirty, c->unchecked_size,
c->sector_size);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
...@@ -96,12 +98,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -96,12 +98,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size; avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size;
if ( (avail / c->sector_size) <= blocksneeded) { if ( (avail / c->sector_size) <= blocksneeded) {
if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) {
D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on possibly available space, but it's a deletion. Allowing...\n")); jffs2_dbg(1, "%s(): Low on possibly available space, but it's a deletion. Allowing...\n",
__func__);
break; break;
} }
D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", jffs2_dbg(1, "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n",
avail, blocksneeded * c->sector_size)); avail, blocksneeded * c->sector_size);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
return -ENOSPC; return -ENOSPC;
...@@ -109,9 +112,14 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -109,9 +112,14 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", jffs2_dbg(1, "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n",
c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, c->nr_free_blocks, c->nr_erasing_blocks,
c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); c->free_size, c->dirty_size, c->wasted_size,
c->used_size, c->erasing_size, c->bad_size,
c->free_size + c->dirty_size +
c->wasted_size + c->used_size +
c->erasing_size + c->bad_size,
c->flash_size);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
ret = jffs2_garbage_collect_pass(c); ret = jffs2_garbage_collect_pass(c);
...@@ -124,7 +132,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -124,7 +132,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&c->erase_wait, &wait); add_wait_queue(&c->erase_wait, &wait);
D1(printk(KERN_DEBUG "%s waiting for erase to complete\n", __func__)); jffs2_dbg(1, "%s waiting for erase to complete\n",
__func__);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
schedule(); schedule();
...@@ -144,7 +153,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -144,7 +153,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
ret = jffs2_do_reserve_space(c, minsize, len, sumsize); ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); jffs2_dbg(1, "%s(): ret is %d\n", __func__, ret);
} }
} }
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -161,13 +170,14 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -161,13 +170,14 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
int ret = -EAGAIN; int ret = -EAGAIN;
minsize = PAD(minsize); minsize = PAD(minsize);
D1(printk(KERN_DEBUG "jffs2_reserve_space_gc(): Requested 0x%x bytes\n", minsize)); jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
while(ret == -EAGAIN) { while(ret == -EAGAIN) {
ret = jffs2_do_reserve_space(c, minsize, len, sumsize); ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); jffs2_dbg(1, "%s(): looping, ret is %d\n",
__func__, ret);
} }
} }
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -184,8 +194,8 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -184,8 +194,8 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo
{ {
if (c->nextblock == NULL) { if (c->nextblock == NULL) {
D1(printk(KERN_DEBUG "jffs2_close_nextblock: Erase block at 0x%08x has already been placed in a list\n", jffs2_dbg(1, "%s(): Erase block at 0x%08x has already been placed in a list\n",
jeb->offset)); __func__, jeb->offset);
return; return;
} }
/* Check, if we have a dirty block now, or if it was dirty already */ /* Check, if we have a dirty block now, or if it was dirty already */
...@@ -195,17 +205,20 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -195,17 +205,20 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo
jeb->dirty_size += jeb->wasted_size; jeb->dirty_size += jeb->wasted_size;
jeb->wasted_size = 0; jeb->wasted_size = 0;
if (VERYDIRTY(c, jeb->dirty_size)) { if (VERYDIRTY(c, jeb->dirty_size)) {
D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", jffs2_dbg(1, "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->used_size);
list_add_tail(&jeb->list, &c->very_dirty_list); list_add_tail(&jeb->list, &c->very_dirty_list);
} else { } else {
D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", jffs2_dbg(1, "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->used_size);
list_add_tail(&jeb->list, &c->dirty_list); list_add_tail(&jeb->list, &c->dirty_list);
} }
} else { } else {
D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->used_size);
list_add_tail(&jeb->list, &c->clean_list); list_add_tail(&jeb->list, &c->clean_list);
} }
c->nextblock = NULL; c->nextblock = NULL;
...@@ -230,13 +243,14 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) ...@@ -230,13 +243,14 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
list_move_tail(&ejeb->list, &c->erase_pending_list); list_move_tail(&ejeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n", jffs2_dbg(1, "%s(): Triggering erase of erasable block at 0x%08x\n",
ejeb->offset)); __func__, ejeb->offset);
} }
if (!c->nr_erasing_blocks && if (!c->nr_erasing_blocks &&
!list_empty(&c->erasable_pending_wbuf_list)) { !list_empty(&c->erasable_pending_wbuf_list)) {
D1(printk(KERN_DEBUG "jffs2_find_nextblock: Flushing write buffer\n")); jffs2_dbg(1, "%s(): Flushing write buffer\n",
__func__);
/* c->nextblock is NULL, no update to c->nextblock allowed */ /* c->nextblock is NULL, no update to c->nextblock allowed */
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
jffs2_flush_wbuf_pad(c); jffs2_flush_wbuf_pad(c);
...@@ -278,7 +292,8 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) ...@@ -278,7 +292,8 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
c->wbuf_ofs = 0xffffffff; c->wbuf_ofs = 0xffffffff;
#endif #endif
D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n",
__func__, c->nextblock->offset);
return 0; return 0;
} }
...@@ -345,7 +360,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -345,7 +360,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
if (jffs2_wbuf_dirty(c)) { if (jffs2_wbuf_dirty(c)) {
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); jffs2_dbg(1, "%s(): Flushing write buffer\n",
__func__);
jffs2_flush_wbuf_pad(c); jffs2_flush_wbuf_pad(c);
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
jeb = c->nextblock; jeb = c->nextblock;
...@@ -408,8 +424,9 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ...@@ -408,8 +424,9 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
} }
D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", jffs2_dbg(1, "%s(): Giving 0x%x bytes at 0x%x\n",
*len, jeb->offset + (c->sector_size - jeb->free_size))); __func__,
*len, jeb->offset + (c->sector_size - jeb->free_size));
return 0; return 0;
} }
...@@ -434,8 +451,8 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, ...@@ -434,8 +451,8 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
jeb = &c->blocks[ofs / c->sector_size]; jeb = &c->blocks[ofs / c->sector_size];
D1(printk(KERN_DEBUG "jffs2_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", jffs2_dbg(1, "%s(): Node at 0x%x(%d), size 0x%x\n",
ofs & ~3, ofs & 3, len)); __func__, ofs & ~3, ofs & 3, len);
#if 1 #if 1
/* Allow non-obsolete nodes only to be added at the end of c->nextblock, /* Allow non-obsolete nodes only to be added at the end of c->nextblock,
if c->nextblock is set. Note that wbuf.c will file obsolete nodes if c->nextblock is set. Note that wbuf.c will file obsolete nodes
...@@ -457,8 +474,9 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, ...@@ -457,8 +474,9 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
/* If it lives on the dirty_list, jffs2_reserve_space will put it there */ /* If it lives on the dirty_list, jffs2_reserve_space will put it there */
D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->used_size);
if (jffs2_wbuf_dirty(c)) { if (jffs2_wbuf_dirty(c)) {
/* Flush the last write in the block if it's outstanding */ /* Flush the last write in the block if it's outstanding */
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -480,7 +498,7 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, ...@@ -480,7 +498,7 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
void jffs2_complete_reservation(struct jffs2_sb_info *c) void jffs2_complete_reservation(struct jffs2_sb_info *c)
{ {
D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); jffs2_dbg(1, "jffs2_complete_reservation()\n");
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -493,7 +511,7 @@ static inline int on_list(struct list_head *obj, struct list_head *head) ...@@ -493,7 +511,7 @@ static inline int on_list(struct list_head *obj, struct list_head *head)
list_for_each(this, head) { list_for_each(this, head) {
if (this == obj) { if (this == obj) {
D1(printk("%p is on list at %p\n", obj, head)); jffs2_dbg(1, "%p is on list at %p\n", obj, head);
return 1; return 1;
} }
...@@ -515,7 +533,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -515,7 +533,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
return; return;
} }
if (ref_obsolete(ref)) { if (ref_obsolete(ref)) {
D1(printk(KERN_DEBUG "jffs2_mark_node_obsolete called with already obsolete node at 0x%08x\n", ref_offset(ref))); jffs2_dbg(1, "%s(): called with already obsolete node at 0x%08x\n",
__func__, ref_offset(ref));
return; return;
} }
blocknr = ref->flash_offset / c->sector_size; blocknr = ref->flash_offset / c->sector_size;
...@@ -546,7 +565,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -546,7 +565,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
freed_len, blocknr, ref->flash_offset, jeb->used_size); freed_len, blocknr, ref->flash_offset, jeb->used_size);
BUG(); BUG();
}) })
D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), freed_len)); jffs2_dbg(1, "Obsoleting previously unchecked node at 0x%08x of len %x\n",
ref_offset(ref), freed_len);
jeb->unchecked_size -= freed_len; jeb->unchecked_size -= freed_len;
c->unchecked_size -= freed_len; c->unchecked_size -= freed_len;
} else { } else {
...@@ -555,14 +575,15 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -555,14 +575,15 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
freed_len, blocknr, ref->flash_offset, jeb->used_size); freed_len, blocknr, ref->flash_offset, jeb->used_size);
BUG(); BUG();
}) })
D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), freed_len)); jffs2_dbg(1, "Obsoleting node at 0x%08x of len %#x: ",
ref_offset(ref), freed_len);
jeb->used_size -= freed_len; jeb->used_size -= freed_len;
c->used_size -= freed_len; c->used_size -= freed_len;
} }
// Take care, that wasted size is taken into concern // Take care, that wasted size is taken into concern
if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) {
D1(printk("Dirtying\n")); jffs2_dbg(1, "Dirtying\n");
addedsize = freed_len; addedsize = freed_len;
jeb->dirty_size += freed_len; jeb->dirty_size += freed_len;
c->dirty_size += freed_len; c->dirty_size += freed_len;
...@@ -570,12 +591,12 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -570,12 +591,12 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
/* Convert wasted space to dirty, if not a bad block */ /* Convert wasted space to dirty, if not a bad block */
if (jeb->wasted_size) { if (jeb->wasted_size) {
if (on_list(&jeb->list, &c->bad_used_list)) { if (on_list(&jeb->list, &c->bad_used_list)) {
D1(printk(KERN_DEBUG "Leaving block at %08x on the bad_used_list\n", jffs2_dbg(1, "Leaving block at %08x on the bad_used_list\n",
jeb->offset)); jeb->offset);
addedsize = 0; /* To fool the refiling code later */ addedsize = 0; /* To fool the refiling code later */
} else { } else {
D1(printk(KERN_DEBUG "Converting %d bytes of wasted space to dirty in block at %08x\n", jffs2_dbg(1, "Converting %d bytes of wasted space to dirty in block at %08x\n",
jeb->wasted_size, jeb->offset)); jeb->wasted_size, jeb->offset);
addedsize += jeb->wasted_size; addedsize += jeb->wasted_size;
jeb->dirty_size += jeb->wasted_size; jeb->dirty_size += jeb->wasted_size;
c->dirty_size += jeb->wasted_size; c->dirty_size += jeb->wasted_size;
...@@ -584,7 +605,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -584,7 +605,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
} }
} }
} else { } else {
D1(printk("Wasting\n")); jffs2_dbg(1, "Wasting\n");
addedsize = 0; addedsize = 0;
jeb->wasted_size += freed_len; jeb->wasted_size += freed_len;
c->wasted_size += freed_len; c->wasted_size += freed_len;
...@@ -606,50 +627,57 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -606,50 +627,57 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
} }
if (jeb == c->nextblock) { if (jeb == c->nextblock) {
D2(printk(KERN_DEBUG "Not moving nextblock 0x%08x to dirty/erase_pending list\n", jeb->offset)); jffs2_dbg(2, "Not moving nextblock 0x%08x to dirty/erase_pending list\n",
jeb->offset);
} else if (!jeb->used_size && !jeb->unchecked_size) { } else if (!jeb->used_size && !jeb->unchecked_size) {
if (jeb == c->gcblock) { if (jeb == c->gcblock) {
D1(printk(KERN_DEBUG "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", jeb->offset)); jffs2_dbg(1, "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n",
jeb->offset);
c->gcblock = NULL; c->gcblock = NULL;
} else { } else {
D1(printk(KERN_DEBUG "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", jeb->offset)); jffs2_dbg(1, "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n",
jeb->offset);
list_del(&jeb->list); list_del(&jeb->list);
} }
if (jffs2_wbuf_dirty(c)) { if (jffs2_wbuf_dirty(c)) {
D1(printk(KERN_DEBUG "...and adding to erasable_pending_wbuf_list\n")); jffs2_dbg(1, "...and adding to erasable_pending_wbuf_list\n");
list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list); list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list);
} else { } else {
if (jiffies & 127) { if (jiffies & 127) {
/* Most of the time, we just erase it immediately. Otherwise we /* Most of the time, we just erase it immediately. Otherwise we
spend ages scanning it on mount, etc. */ spend ages scanning it on mount, etc. */
D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); jffs2_dbg(1, "...and adding to erase_pending_list\n");
list_add_tail(&jeb->list, &c->erase_pending_list); list_add_tail(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
} else { } else {
/* Sometimes, however, we leave it elsewhere so it doesn't get /* Sometimes, however, we leave it elsewhere so it doesn't get
immediately reused, and we spread the load a bit. */ immediately reused, and we spread the load a bit. */
D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); jffs2_dbg(1, "...and adding to erasable_list\n");
list_add_tail(&jeb->list, &c->erasable_list); list_add_tail(&jeb->list, &c->erasable_list);
} }
} }
D1(printk(KERN_DEBUG "Done OK\n")); jffs2_dbg(1, "Done OK\n");
} else if (jeb == c->gcblock) { } else if (jeb == c->gcblock) {
D2(printk(KERN_DEBUG "Not moving gcblock 0x%08x to dirty_list\n", jeb->offset)); jffs2_dbg(2, "Not moving gcblock 0x%08x to dirty_list\n",
jeb->offset);
} else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) { } else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) {
D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", jeb->offset)); jffs2_dbg(1, "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n",
jeb->offset);
list_del(&jeb->list); list_del(&jeb->list);
D1(printk(KERN_DEBUG "...and adding to dirty_list\n")); jffs2_dbg(1, "...and adding to dirty_list\n");
list_add_tail(&jeb->list, &c->dirty_list); list_add_tail(&jeb->list, &c->dirty_list);
} else if (VERYDIRTY(c, jeb->dirty_size) && } else if (VERYDIRTY(c, jeb->dirty_size) &&
!VERYDIRTY(c, jeb->dirty_size - addedsize)) { !VERYDIRTY(c, jeb->dirty_size - addedsize)) {
D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", jeb->offset)); jffs2_dbg(1, "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n",
jeb->offset);
list_del(&jeb->list); list_del(&jeb->list);
D1(printk(KERN_DEBUG "...and adding to very_dirty_list\n")); jffs2_dbg(1, "...and adding to very_dirty_list\n");
list_add_tail(&jeb->list, &c->very_dirty_list); list_add_tail(&jeb->list, &c->very_dirty_list);
} else { } else {
D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", jffs2_dbg(1, "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->used_size);
} }
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
...@@ -665,7 +693,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -665,7 +693,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet
by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */ by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */
D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref))); jffs2_dbg(1, "obliterating obsoleted node at 0x%08x\n",
ref_offset(ref));
ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
if (ret) { if (ret) {
printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret); printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
...@@ -680,7 +709,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref ...@@ -680,7 +709,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
goto out_erase_sem; goto out_erase_sem;
} }
if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) {
D1(printk(KERN_DEBUG "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", ref_offset(ref), je16_to_cpu(n.nodetype))); jffs2_dbg(1, "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n",
ref_offset(ref), je16_to_cpu(n.nodetype));
goto out_erase_sem; goto out_erase_sem;
} }
/* XXX FIXME: This is ugly now */ /* XXX FIXME: This is ugly now */
...@@ -751,8 +781,8 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) ...@@ -751,8 +781,8 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c)
return 1; return 1;
if (c->unchecked_size) { if (c->unchecked_size) {
D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", jffs2_dbg(1, "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n",
c->unchecked_size, c->checked_ino)); c->unchecked_size, c->checked_ino);
return 1; return 1;
} }
...@@ -780,8 +810,9 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) ...@@ -780,8 +810,9 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c)
} }
} }
D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n", jffs2_dbg(1, "%s(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n",
c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, nr_very_dirty, ret?"yes":"no")); __func__, c->nr_free_blocks, c->nr_erasing_blocks,
c->dirty_size, nr_very_dirty, ret ? "yes" : "no");
return ret; return ret;
} }
...@@ -47,10 +47,10 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -47,10 +47,10 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
} }
crc = crc32(0, ri, sizeof(*ri)-8); crc = crc32(0, ri, sizeof(*ri)-8);
D1(printk(KERN_DEBUG "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n", jffs2_dbg(1, "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n",
ref_offset(fd->raw), je32_to_cpu(ri->node_crc), ref_offset(fd->raw), je32_to_cpu(ri->node_crc),
crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize),
je32_to_cpu(ri->offset), buf)); je32_to_cpu(ri->offset), buf);
if (crc != je32_to_cpu(ri->node_crc)) { if (crc != je32_to_cpu(ri->node_crc)) {
printk(KERN_WARNING "Node CRC %08x != calculated CRC %08x for node at %08x\n", printk(KERN_WARNING "Node CRC %08x != calculated CRC %08x for node at %08x\n",
je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw));
...@@ -107,8 +107,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -107,8 +107,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
decomprbuf = readbuf; decomprbuf = readbuf;
} }
D2(printk(KERN_DEBUG "Read %d bytes to %p\n", je32_to_cpu(ri->csize), jffs2_dbg(2, "Read %d bytes to %p\n", je32_to_cpu(ri->csize),
readbuf)); readbuf);
ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri),
je32_to_cpu(ri->csize), &readlen, readbuf); je32_to_cpu(ri->csize), &readlen, readbuf);
...@@ -124,10 +124,11 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -124,10 +124,11 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
ret = -EIO; ret = -EIO;
goto out_decomprbuf; goto out_decomprbuf;
} }
D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); jffs2_dbg(2, "Data CRC matches calculated CRC %08x\n", crc);
if (ri->compr != JFFS2_COMPR_NONE) { if (ri->compr != JFFS2_COMPR_NONE) {
D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", jffs2_dbg(2, "Decompress %d bytes from %p to %d bytes at %p\n",
je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); je32_to_cpu(ri->csize), readbuf,
je32_to_cpu(ri->dsize), decomprbuf);
ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize));
if (ret) { if (ret) {
printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret);
...@@ -157,8 +158,8 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -157,8 +158,8 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
struct jffs2_node_frag *frag; struct jffs2_node_frag *frag;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_read_inode_range: ino #%u, range 0x%08x-0x%08x\n", jffs2_dbg(1, "%s(): ino #%u, range 0x%08x-0x%08x\n",
f->inocache->ino, offset, offset+len)); __func__, f->inocache->ino, offset, offset + len);
frag = jffs2_lookup_node_frag(&f->fragtree, offset); frag = jffs2_lookup_node_frag(&f->fragtree, offset);
...@@ -168,22 +169,27 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -168,22 +169,27 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
* (or perhaps is before it, if we've been asked to read off the * (or perhaps is before it, if we've been asked to read off the
* end of the file). */ * end of the file). */
while(offset < end) { while(offset < end) {
D2(printk(KERN_DEBUG "jffs2_read_inode_range: offset %d, end %d\n", offset, end)); jffs2_dbg(2, "%s(): offset %d, end %d\n",
__func__, offset, end);
if (unlikely(!frag || frag->ofs > offset || if (unlikely(!frag || frag->ofs > offset ||
frag->ofs + frag->size <= offset)) { frag->ofs + frag->size <= offset)) {
uint32_t holesize = end - offset; uint32_t holesize = end - offset;
if (frag && frag->ofs > offset) { if (frag && frag->ofs > offset) {
D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset)); jffs2_dbg(1, "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n",
f->inocache->ino, frag->ofs, offset);
holesize = min(holesize, frag->ofs - offset); holesize = min(holesize, frag->ofs - offset);
} }
D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); jffs2_dbg(1, "Filling non-frag hole from %d-%d\n",
offset, offset + holesize);
memset(buf, 0, holesize); memset(buf, 0, holesize);
buf += holesize; buf += holesize;
offset += holesize; offset += holesize;
continue; continue;
} else if (unlikely(!frag->node)) { } else if (unlikely(!frag->node)) {
uint32_t holeend = min(end, frag->ofs + frag->size); uint32_t holeend = min(end, frag->ofs + frag->size);
D1(printk(KERN_DEBUG "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", offset, holeend, frag->ofs, frag->ofs + frag->size)); jffs2_dbg(1, "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n",
offset, holeend, frag->ofs,
frag->ofs + frag->size);
memset(buf, 0, holeend - offset); memset(buf, 0, holeend - offset);
buf += holeend - offset; buf += holeend - offset;
offset = holeend; offset = holeend;
...@@ -195,20 +201,23 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -195,20 +201,23 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
fragofs = offset - frag->ofs; fragofs = offset - frag->ofs;
readlen = min(frag->size - fragofs, end - offset); readlen = min(frag->size - fragofs, end - offset);
D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n", jffs2_dbg(1, "Reading %d-%d from node at 0x%08x (%d)\n",
frag->ofs+fragofs, frag->ofs+fragofs+readlen, frag->ofs+fragofs,
ref_offset(frag->node->raw), ref_flags(frag->node->raw))); frag->ofs + fragofs+readlen,
ref_offset(frag->node->raw),
ref_flags(frag->node->raw));
ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen);
D2(printk(KERN_DEBUG "node read done\n")); jffs2_dbg(2, "node read done\n");
if (ret) { if (ret) {
D1(printk(KERN_DEBUG"jffs2_read_inode_range error %d\n",ret)); jffs2_dbg(1, "%s(): error %d\n",
__func__, ret);
memset(buf, 0, readlen); memset(buf, 0, readlen);
return ret; return ret;
} }
buf += readlen; buf += readlen;
offset += readlen; offset += readlen;
frag = frag_next(frag); frag = frag_next(frag);
D2(printk(KERN_DEBUG "node read was OK. Looping\n")); jffs2_dbg(2, "node read was OK. Looping\n");
} }
} }
return 0; return 0;
......
...@@ -100,12 +100,13 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -100,12 +100,13 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
(void **)&flashbuf, NULL); (void **)&flashbuf, NULL);
if (!ret && pointlen < c->mtd->size) { if (!ret && pointlen < c->mtd->size) {
/* Don't muck about if it won't let us point to the whole flash */ /* Don't muck about if it won't let us point to the whole flash */
D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen)); jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n",
pointlen);
mtd_unpoint(c->mtd, 0, pointlen); mtd_unpoint(c->mtd, 0, pointlen);
flashbuf = NULL; flashbuf = NULL;
} }
if (ret && ret != -EOPNOTSUPP) if (ret && ret != -EOPNOTSUPP)
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); jffs2_dbg(1, "MTD point failed %d\n", ret);
#endif #endif
if (!flashbuf) { if (!flashbuf) {
/* For NAND it's quicker to read a whole eraseblock at a time, /* For NAND it's quicker to read a whole eraseblock at a time,
...@@ -115,15 +116,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -115,15 +116,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
else else
try_size = PAGE_SIZE; try_size = PAGE_SIZE;
D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu " jffs2_dbg(1, "Trying to allocate readbuf of %zu "
"bytes\n", try_size)); "bytes\n", try_size);
flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
if (!flashbuf) if (!flashbuf)
return -ENOMEM; return -ENOMEM;
D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n", jffs2_dbg(1, "Allocated readbuf of %zu bytes\n",
try_size)); try_size);
buf_size = (uint32_t)try_size; buf_size = (uint32_t)try_size;
} }
...@@ -176,7 +177,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -176,7 +177,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
c->nr_free_blocks++; c->nr_free_blocks++;
} else { } else {
/* Dirt */ /* Dirt */
D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset)); jffs2_dbg(1, "Adding all-dirty block at 0x%08x to erase_pending_list\n",
jeb->offset);
list_add(&jeb->list, &c->erase_pending_list); list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
} }
...@@ -203,7 +205,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -203,7 +205,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
} }
/* update collected summary information for the current nextblock */ /* update collected summary information for the current nextblock */
jffs2_sum_move_collected(c, s); jffs2_sum_move_collected(c, s);
D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n",
__func__, jeb->offset);
c->nextblock = jeb; c->nextblock = jeb;
} else { } else {
ret = file_dirty(c, jeb); ret = file_dirty(c, jeb);
...@@ -215,13 +218,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -215,13 +218,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
case BLK_STATE_ALLDIRTY: case BLK_STATE_ALLDIRTY:
/* Nothing valid - not even a clean marker. Needs erasing. */ /* Nothing valid - not even a clean marker. Needs erasing. */
/* For now we just put it on the erasing list. We'll start the erases later */ /* For now we just put it on the erasing list. We'll start the erases later */
D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset)); jffs2_dbg(1, "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n",
jeb->offset);
list_add(&jeb->list, &c->erase_pending_list); list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
break; break;
case BLK_STATE_BADBLOCK: case BLK_STATE_BADBLOCK:
D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); jffs2_dbg(1, "JFFS2: Block at 0x%08x is bad\n",
jeb->offset);
list_add(&jeb->list, &c->bad_list); list_add(&jeb->list, &c->bad_list);
c->bad_size += c->sector_size; c->bad_size += c->sector_size;
c->free_size -= c->sector_size; c->free_size -= c->sector_size;
...@@ -248,8 +253,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -248,8 +253,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize;
D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n", jffs2_dbg(1, "%s(): Skipping %d bytes in nextblock to ensure page alignment\n",
skip)); __func__, skip);
jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); jffs2_prealloc_raw_node_refs(c, c->nextblock, 1);
jffs2_scan_dirty_space(c, c->nextblock, skip); jffs2_scan_dirty_space(c, c->nextblock, skip);
} }
...@@ -285,11 +290,13 @@ static int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, ...@@ -285,11 +290,13 @@ static int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf,
ret = jffs2_flash_read(c, ofs, len, &retlen, buf); ret = jffs2_flash_read(c, ofs, len, &retlen, buf);
if (ret) { if (ret) {
D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret)); jffs2_dbg(1, "mtd->read(0x%x bytes from 0x%x) returned %d\n",
len, ofs, ret);
return ret; return ret;
} }
if (retlen < len) { if (retlen < len) {
D1(printk(KERN_WARNING "Read at 0x%x gave only 0x%zx bytes\n", ofs, retlen)); jffs2_dbg(1, "Read at 0x%x gave only 0x%zx bytes\n",
ofs, retlen);
return -EIO; return -EIO;
} }
return 0; return 0;
...@@ -447,7 +454,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -447,7 +454,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
ofs = jeb->offset; ofs = jeb->offset;
prevofs = jeb->offset - 1; prevofs = jeb->offset - 1;
D1(printk(KERN_DEBUG "jffs2_scan_eraseblock(): Scanning block at 0x%x\n", ofs)); jffs2_dbg(1, "%s(): Scanning block at 0x%x\n", __func__, ofs);
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
if (jffs2_cleanmarker_oob(c)) { if (jffs2_cleanmarker_oob(c)) {
...@@ -457,7 +464,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -457,7 +464,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
return BLK_STATE_BADBLOCK; return BLK_STATE_BADBLOCK;
ret = jffs2_check_nand_cleanmarker(c, jeb); ret = jffs2_check_nand_cleanmarker(c, jeb);
D2(printk(KERN_NOTICE "jffs_check_nand_cleanmarker returned %d\n",ret)); jffs2_dbg(2, "jffs_check_nand_cleanmarker returned %d\n", ret);
/* Even if it's not found, we still scan to see /* Even if it's not found, we still scan to see
if the block is empty. We use this information if the block is empty. We use this information
...@@ -559,7 +566,8 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -559,7 +566,8 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (jffs2_cleanmarker_oob(c)) { if (jffs2_cleanmarker_oob(c)) {
/* scan oob, take care of cleanmarker */ /* scan oob, take care of cleanmarker */
int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound);
D2(printk(KERN_NOTICE "jffs2_check_oob_empty returned %d\n",ret)); jffs2_dbg(2, "jffs2_check_oob_empty returned %d\n",
ret);
switch (ret) { switch (ret) {
case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF; case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF;
case 1: return BLK_STATE_ALLDIRTY; case 1: return BLK_STATE_ALLDIRTY;
...@@ -567,15 +575,16 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -567,15 +575,16 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
} }
} }
#endif #endif
D1(printk(KERN_DEBUG "Block at 0x%08x is empty (erased)\n", jeb->offset)); jffs2_dbg(1, "Block at 0x%08x is empty (erased)\n",
jeb->offset);
if (c->cleanmarker_size == 0) if (c->cleanmarker_size == 0)
return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */ return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */
else else
return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */ return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */
} }
if (ofs) { if (ofs) {
D1(printk(KERN_DEBUG "Free space at %08x ends at %08x\n", jeb->offset, jffs2_dbg(1, "Free space at %08x ends at %08x\n", jeb->offset,
jeb->offset + ofs)); jeb->offset + ofs);
if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1)))
return err; return err;
if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) if ((err = jffs2_scan_dirty_space(c, jeb, ofs)))
...@@ -616,8 +625,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -616,8 +625,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
prevofs = ofs; prevofs = ofs;
if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { if (jeb->offset + c->sector_size < ofs + sizeof(*node)) {
D1(printk(KERN_DEBUG "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n", sizeof(struct jffs2_unknown_node), jffs2_dbg(1, "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n",
jeb->offset, c->sector_size, ofs, sizeof(*node))); sizeof(struct jffs2_unknown_node),
jeb->offset, c->sector_size, ofs,
sizeof(*node));
if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs)))
return err; return err;
break; break;
...@@ -625,8 +636,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -625,8 +636,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (buf_ofs + buf_len < ofs + sizeof(*node)) { if (buf_ofs + buf_len < ofs + sizeof(*node)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
D1(printk(KERN_DEBUG "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n", jffs2_dbg(1, "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n",
sizeof(struct jffs2_unknown_node), buf_len, ofs)); sizeof(struct jffs2_unknown_node),
buf_len, ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -643,7 +655,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -643,7 +655,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
ofs += 4; ofs += 4;
scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len); scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len);
D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs)); jffs2_dbg(1, "Found empty flash at 0x%08x\n", ofs);
more_empty: more_empty:
inbuf_ofs = ofs - buf_ofs; inbuf_ofs = ofs - buf_ofs;
while (inbuf_ofs < scan_end) { while (inbuf_ofs < scan_end) {
...@@ -659,13 +671,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -659,13 +671,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
ofs += 4; ofs += 4;
} }
/* Ran off end. */ /* Ran off end. */
D1(printk(KERN_DEBUG "Empty flash to end of buffer at 0x%08x\n", ofs)); jffs2_dbg(1, "Empty flash to end of buffer at 0x%08x\n",
ofs);
/* If we're only checking the beginning of a block with a cleanmarker, /* If we're only checking the beginning of a block with a cleanmarker,
bail now */ bail now */
if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) &&
c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) {
D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); jffs2_dbg(1, "%d bytes at start of block seems clean... assuming all clean\n",
EMPTY_SCAN_SIZE(c->sector_size));
return BLK_STATE_CLEANMARKER; return BLK_STATE_CLEANMARKER;
} }
if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */ if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */
...@@ -678,13 +692,14 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -678,13 +692,14 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (!buf_len) { if (!buf_len) {
/* No more to read. Break out of main loop without marking /* No more to read. Break out of main loop without marking
this range of empty space as dirty (because it's not) */ this range of empty space as dirty (because it's not) */
D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", jffs2_dbg(1, "Empty flash at %08x runs to end of block. Treating as free_space\n",
empty_start)); empty_start);
break; break;
} }
/* point never reaches here */ /* point never reaches here */
scan_end = buf_len; scan_end = buf_len;
D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs)); jffs2_dbg(1, "Reading another 0x%x at 0x%08x\n",
buf_len, ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -700,7 +715,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -700,7 +715,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
continue; continue;
} }
if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) { if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) {
D1(printk(KERN_DEBUG "Dirty bitmask at 0x%08x\n", ofs)); jffs2_dbg(1, "Dirty bitmask at 0x%08x\n", ofs);
if ((err = jffs2_scan_dirty_space(c, jeb, 4))) if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
return err; return err;
ofs += 4; ofs += 4;
...@@ -756,7 +771,8 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -756,7 +771,8 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) { if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) {
/* Wheee. This is an obsoleted node */ /* Wheee. This is an obsoleted node */
D2(printk(KERN_DEBUG "Node at 0x%08x is obsolete. Skipping\n", ofs)); jffs2_dbg(2, "Node at 0x%08x is obsolete. Skipping\n",
ofs);
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen)))))
return err; return err;
ofs += PAD(je32_to_cpu(node->totlen)); ofs += PAD(je32_to_cpu(node->totlen));
...@@ -767,8 +783,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -767,8 +783,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
case JFFS2_NODETYPE_INODE: case JFFS2_NODETYPE_INODE:
if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
D1(printk(KERN_DEBUG "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n", jffs2_dbg(1, "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n",
sizeof(struct jffs2_raw_inode), buf_len, ofs)); sizeof(struct jffs2_raw_inode),
buf_len, ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -783,8 +800,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -783,8 +800,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
case JFFS2_NODETYPE_DIRENT: case JFFS2_NODETYPE_DIRENT:
if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
D1(printk(KERN_DEBUG "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n", jffs2_dbg(1, "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n",
je32_to_cpu(node->totlen), buf_len, ofs)); je32_to_cpu(node->totlen), buf_len,
ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -800,9 +818,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -800,9 +818,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
case JFFS2_NODETYPE_XATTR: case JFFS2_NODETYPE_XATTR:
if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
D1(printk(KERN_DEBUG "Fewer than %d bytes (xattr node)" jffs2_dbg(1, "Fewer than %d bytes (xattr node) left to end of buf. Reading 0x%x at 0x%08x\n",
" left to end of buf. Reading 0x%x at 0x%08x\n", je32_to_cpu(node->totlen), buf_len,
je32_to_cpu(node->totlen), buf_len, ofs)); ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -817,9 +835,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -817,9 +835,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
case JFFS2_NODETYPE_XREF: case JFFS2_NODETYPE_XREF:
if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) {
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
D1(printk(KERN_DEBUG "Fewer than %d bytes (xref node)" jffs2_dbg(1, "Fewer than %d bytes (xref node) left to end of buf. Reading 0x%x at 0x%08x\n",
" left to end of buf. Reading 0x%x at 0x%08x\n", je32_to_cpu(node->totlen), buf_len,
je32_to_cpu(node->totlen), buf_len, ofs)); ofs);
err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
if (err) if (err)
return err; return err;
...@@ -834,7 +852,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -834,7 +852,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
#endif /* CONFIG_JFFS2_FS_XATTR */ #endif /* CONFIG_JFFS2_FS_XATTR */
case JFFS2_NODETYPE_CLEANMARKER: case JFFS2_NODETYPE_CLEANMARKER:
D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); jffs2_dbg(1, "CLEANMARKER node found at 0x%08x\n", ofs);
if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { if (je32_to_cpu(node->totlen) != c->cleanmarker_size) {
printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n",
ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); ofs, je32_to_cpu(node->totlen), c->cleanmarker_size);
...@@ -878,14 +896,16 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -878,14 +896,16 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
return -EINVAL; return -EINVAL;
case JFFS2_FEATURE_RWCOMPAT_DELETE: case JFFS2_FEATURE_RWCOMPAT_DELETE:
D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n",
je16_to_cpu(node->nodetype), ofs);
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen)))))
return err; return err;
ofs += PAD(je32_to_cpu(node->totlen)); ofs += PAD(je32_to_cpu(node->totlen));
break; break;
case JFFS2_FEATURE_RWCOMPAT_COPY: { case JFFS2_FEATURE_RWCOMPAT_COPY: {
D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n",
je16_to_cpu(node->nodetype), ofs);
jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL);
...@@ -906,8 +926,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -906,8 +926,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
} }
} }
D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size)); jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
/* mark_node_obsolete can add to wasted !! */ /* mark_node_obsolete can add to wasted !! */
if (jeb->wasted_size) { if (jeb->wasted_size) {
...@@ -952,7 +973,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc ...@@ -952,7 +973,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
struct jffs2_inode_cache *ic; struct jffs2_inode_cache *ic;
uint32_t crc, ino = je32_to_cpu(ri->ino); uint32_t crc, ino = je32_to_cpu(ri->ino);
D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs);
/* We do very little here now. Just check the ino# to which we should attribute /* We do very little here now. Just check the ino# to which we should attribute
this node; we can do all the CRC checking etc. later. There's a tradeoff here -- this node; we can do all the CRC checking etc. later. There's a tradeoff here --
...@@ -987,10 +1008,10 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc ...@@ -987,10 +1008,10 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
/* Wheee. It worked */ /* Wheee. It worked */
jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic);
D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", jffs2_dbg(1, "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
je32_to_cpu(ri->ino), je32_to_cpu(ri->version), je32_to_cpu(ri->ino), je32_to_cpu(ri->version),
je32_to_cpu(ri->offset), je32_to_cpu(ri->offset),
je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize));
pseudo_random += je32_to_cpu(ri->version); pseudo_random += je32_to_cpu(ri->version);
...@@ -1010,7 +1031,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -1010,7 +1031,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
uint32_t crc; uint32_t crc;
int err; int err;
D1(printk(KERN_DEBUG "jffs2_scan_dirent_node(): Node at 0x%08x\n", ofs)); jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs);
/* We don't get here unless the node is still valid, so we don't have to /* We don't get here unless the node is still valid, so we don't have to
mask in the ACCURATE bit any more. */ mask in the ACCURATE bit any more. */
...@@ -1044,7 +1065,8 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -1044,7 +1065,8 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
if (crc != je32_to_cpu(rd->name_crc)) { if (crc != je32_to_cpu(rd->name_crc)) {
printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
ofs, je32_to_cpu(rd->name_crc), crc); ofs, je32_to_cpu(rd->name_crc), crc);
D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); jffs2_dbg(1, "Name for which CRC failed is (now) '%s', ino #%d\n",
fd->name, je32_to_cpu(rd->ino));
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
/* FIXME: Why do we believe totlen? */ /* FIXME: Why do we believe totlen? */
/* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */ /* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */
......
...@@ -69,7 +69,7 @@ static void jffs2_write_super(struct super_block *sb) ...@@ -69,7 +69,7 @@ static void jffs2_write_super(struct super_block *sb)
sb->s_dirt = 0; sb->s_dirt = 0;
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
D1(printk(KERN_DEBUG "jffs2_write_super()\n")); jffs2_dbg(1, "%s()\n", __func__);
jffs2_flush_wbuf_gc(c, 0); jffs2_flush_wbuf_gc(c, 0);
} }
...@@ -266,9 +266,9 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -266,9 +266,9 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
struct jffs2_sb_info *c; struct jffs2_sb_info *c;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" jffs2_dbg(1, "jffs2_get_sb_mtd():"
" New superblock for device %d (\"%s\")\n", " New superblock for device %d (\"%s\")\n",
sb->s_mtd->index, sb->s_mtd->name)); sb->s_mtd->index, sb->s_mtd->name);
c = kzalloc(sizeof(*c), GFP_KERNEL); c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c) if (!c)
...@@ -315,7 +315,7 @@ static void jffs2_put_super (struct super_block *sb) ...@@ -315,7 +315,7 @@ static void jffs2_put_super (struct super_block *sb)
{ {
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); jffs2_dbg(2, "%s()\n", __func__);
if (sb->s_dirt) if (sb->s_dirt)
jffs2_write_super(sb); jffs2_write_super(sb);
...@@ -336,7 +336,7 @@ static void jffs2_put_super (struct super_block *sb) ...@@ -336,7 +336,7 @@ static void jffs2_put_super (struct super_block *sb)
kfree(c->inocache_list); kfree(c->inocache_list);
jffs2_clear_xattr_subsystem(c); jffs2_clear_xattr_subsystem(c);
mtd_sync(c->mtd); mtd_sync(c->mtd);
D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); jffs2_dbg(1, "%s(): returning\n", __func__);
} }
static void jffs2_kill_sb(struct super_block *sb) static void jffs2_kill_sb(struct super_block *sb)
......
...@@ -50,7 +50,8 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -50,7 +50,8 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n"); printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n");
p = ERR_PTR(-EIO); p = ERR_PTR(-EIO);
} }
D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); jffs2_dbg(1, "%s(): target path is '%s'\n",
__func__, (char *)f->target);
nd_set_link(nd, p); nd_set_link(nd, p);
......
...@@ -91,7 +91,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino) ...@@ -91,7 +91,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino)
new = kmalloc(sizeof(*new), GFP_KERNEL); new = kmalloc(sizeof(*new), GFP_KERNEL);
if (!new) { if (!new) {
D1(printk(KERN_DEBUG "No memory to allocate inodirty. Fallback to all considered dirty\n")); jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n");
jffs2_clear_wbuf_ino_list(c); jffs2_clear_wbuf_ino_list(c);
c->wbuf_inodes = &inodirty_nomem; c->wbuf_inodes = &inodirty_nomem;
return; return;
...@@ -113,19 +113,20 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) ...@@ -113,19 +113,20 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) {
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
D1(printk(KERN_DEBUG "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset)); jffs2_dbg(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n",
jeb->offset);
list_del(this); list_del(this);
if ((jiffies + (n++)) & 127) { if ((jiffies + (n++)) & 127) {
/* Most of the time, we just erase it immediately. Otherwise we /* Most of the time, we just erase it immediately. Otherwise we
spend ages scanning it on mount, etc. */ spend ages scanning it on mount, etc. */
D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); jffs2_dbg(1, "...and adding to erase_pending_list\n");
list_add_tail(&jeb->list, &c->erase_pending_list); list_add_tail(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
} else { } else {
/* Sometimes, however, we leave it elsewhere so it doesn't get /* Sometimes, however, we leave it elsewhere so it doesn't get
immediately reused, and we spread the load a bit. */ immediately reused, and we spread the load a bit. */
D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); jffs2_dbg(1, "...and adding to erasable_list\n");
list_add_tail(&jeb->list, &c->erasable_list); list_add_tail(&jeb->list, &c->erasable_list);
} }
} }
...@@ -136,7 +137,7 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) ...@@ -136,7 +137,7 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty)
{ {
D1(printk("About to refile bad block at %08x\n", jeb->offset)); jffs2_dbg(1, "About to refile bad block at %08x\n", jeb->offset);
/* File the existing block on the bad_used_list.... */ /* File the existing block on the bad_used_list.... */
if (c->nextblock == jeb) if (c->nextblock == jeb)
...@@ -144,12 +145,14 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -144,12 +145,14 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
else /* Not sure this should ever happen... need more coffee */ else /* Not sure this should ever happen... need more coffee */
list_del(&jeb->list); list_del(&jeb->list);
if (jeb->first_node) { if (jeb->first_node) {
D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); jffs2_dbg(1, "Refiling block at %08x to bad_used_list\n",
jeb->offset);
list_add(&jeb->list, &c->bad_used_list); list_add(&jeb->list, &c->bad_used_list);
} else { } else {
BUG_ON(allow_empty == REFILE_NOTEMPTY); BUG_ON(allow_empty == REFILE_NOTEMPTY);
/* It has to have had some nodes or we couldn't be here */ /* It has to have had some nodes or we couldn't be here */
D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); jffs2_dbg(1, "Refiling block at %08x to erase_pending_list\n",
jeb->offset);
list_add(&jeb->list, &c->erase_pending_list); list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
...@@ -308,7 +311,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -308,7 +311,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
if (!first_raw) { if (!first_raw) {
/* All nodes were obsolete. Nothing to recover. */ /* All nodes were obsolete. Nothing to recover. */
D1(printk(KERN_DEBUG "No non-obsolete nodes to be recovered. Just filing block bad\n")); jffs2_dbg(1, "No non-obsolete nodes to be recovered. Just filing block bad\n");
c->wbuf_len = 0; c->wbuf_len = 0;
return; return;
} }
...@@ -406,8 +409,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -406,8 +409,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
unsigned char *rewrite_buf = buf?:c->wbuf; unsigned char *rewrite_buf = buf?:c->wbuf;
uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);
D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", jffs2_dbg(1, "Write 0x%x bytes at 0x%08x in wbuf recover\n",
towrite, ofs)); towrite, ofs);
#ifdef BREAKMEHEADER #ifdef BREAKMEHEADER
static int breakme; static int breakme;
...@@ -459,8 +462,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -459,8 +462,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
struct jffs2_raw_node_ref **adjust_ref = NULL; struct jffs2_raw_node_ref **adjust_ref = NULL;
struct jffs2_inode_info *f = NULL; struct jffs2_inode_info *f = NULL;
D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n", jffs2_dbg(1, "Refiling block of %08x at %08x(%d) to %08x\n",
rawlen, ref_offset(raw), ref_flags(raw), ofs)); rawlen, ref_offset(raw), ref_flags(raw), ofs);
ic = jffs2_raw_ref_to_ic(raw); ic = jffs2_raw_ref_to_ic(raw);
...@@ -540,7 +543,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -540,7 +543,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
/* Fix up the original jeb now it's on the bad_list */ /* Fix up the original jeb now it's on the bad_list */
if (first_raw == jeb->first_node) { if (first_raw == jeb->first_node) {
D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset)); jffs2_dbg(1, "Failing block at %08x is now empty. Moving to erase_pending_list\n",
jeb->offset);
list_move(&jeb->list, &c->erase_pending_list); list_move(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++; c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
...@@ -554,7 +558,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -554,7 +558,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
spin_unlock(&c->erase_completion_lock); spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", c->wbuf_ofs, c->wbuf_len)); jffs2_dbg(1, "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n",
c->wbuf_ofs, c->wbuf_len);
} }
...@@ -647,8 +652,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) ...@@ -647,8 +652,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
if (pad) { if (pad) {
uint32_t waste = c->wbuf_pagesize - c->wbuf_len; uint32_t waste = c->wbuf_pagesize - c->wbuf_len;
D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", jffs2_dbg(1, "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n",
(wbuf_jeb==c->nextblock)?"next":"", wbuf_jeb->offset)); (wbuf_jeb == c->nextblock) ? "next" : "",
wbuf_jeb->offset);
/* wbuf_pagesize - wbuf_len is the amount of space that's to be /* wbuf_pagesize - wbuf_len is the amount of space that's to be
padded. If there is less free space in the block than that, padded. If there is less free space in the block than that,
...@@ -694,14 +700,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) ...@@ -694,14 +700,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
uint32_t old_wbuf_len; uint32_t old_wbuf_len;
int ret = 0; int ret = 0;
D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino)); jffs2_dbg(1, "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino);
if (!c->wbuf) if (!c->wbuf)
return 0; return 0;
mutex_lock(&c->alloc_sem); mutex_lock(&c->alloc_sem);
if (!jffs2_wbuf_pending_for_ino(c, ino)) { if (!jffs2_wbuf_pending_for_ino(c, ino)) {
D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); jffs2_dbg(1, "Ino #%d not pending in wbuf. Returning\n", ino);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
return 0; return 0;
} }
...@@ -711,7 +717,8 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) ...@@ -711,7 +717,8 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
if (c->unchecked_size) { if (c->unchecked_size) {
/* GC won't make any progress for a while */ /* GC won't make any progress for a while */
D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() padding. Not finished checking\n")); jffs2_dbg(1, "%s(): padding. Not finished checking\n",
__func__);
down_write(&c->wbuf_sem); down_write(&c->wbuf_sem);
ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
/* retry flushing wbuf in case jffs2_wbuf_recover /* retry flushing wbuf in case jffs2_wbuf_recover
...@@ -724,7 +731,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) ...@@ -724,7 +731,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); jffs2_dbg(1, "%s(): calls gc pass\n", __func__);
ret = jffs2_garbage_collect_pass(c); ret = jffs2_garbage_collect_pass(c);
if (ret) { if (ret) {
...@@ -742,7 +749,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) ...@@ -742,7 +749,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
mutex_lock(&c->alloc_sem); mutex_lock(&c->alloc_sem);
} }
D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); jffs2_dbg(1, "%s(): ends...\n", __func__);
mutex_unlock(&c->alloc_sem); mutex_unlock(&c->alloc_sem);
return ret; return ret;
...@@ -811,9 +818,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, ...@@ -811,9 +818,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) {
/* It's a write to a new block */ /* It's a write to a new block */
if (c->wbuf_len) { if (c->wbuf_len) {
D1(printk(KERN_DEBUG "jffs2_flash_writev() to 0x%lx " jffs2_dbg(1, "%s(): to 0x%lx causes flush of wbuf at 0x%08x\n",
"causes flush of wbuf at 0x%08x\n", __func__, (unsigned long)to, c->wbuf_ofs);
(unsigned long)to, c->wbuf_ofs));
ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT);
if (ret) if (ret)
goto outerr; goto outerr;
...@@ -825,8 +831,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, ...@@ -825,8 +831,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { if (to != PAD(c->wbuf_ofs + c->wbuf_len)) {
/* We're not writing immediately after the writebuffer. Bad. */ /* We're not writing immediately after the writebuffer. Bad. */
printk(KERN_CRIT "jffs2_flash_writev(): Non-contiguous write " printk(KERN_CRIT "%s(): Non-contiguous write to %08lx\n",
"to %08lx\n", (unsigned long)to); __func__, (unsigned long)to);
if (c->wbuf_len) if (c->wbuf_len)
printk(KERN_CRIT "wbuf was previously %08x-%08x\n", printk(KERN_CRIT "wbuf was previously %08x-%08x\n",
c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len); c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len);
...@@ -1048,8 +1054,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, ...@@ -1048,8 +1054,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
continue; continue;
if (ops.oobbuf[i] != 0xFF) { if (ops.oobbuf[i] != 0xFF) {
D2(printk(KERN_DEBUG "Found %02x at %x in OOB for " jffs2_dbg(2, "Found %02x at %x in OOB for "
"%08x\n", ops.oobbuf[i], i, jeb->offset)); "%08x\n", ops.oobbuf[i], i, jeb->offset);
return 1; return 1;
} }
} }
...@@ -1134,7 +1140,8 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * ...@@ -1134,7 +1140,8 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
ret = mtd_block_markbad(c->mtd, bad_offset); ret = mtd_block_markbad(c->mtd, bad_offset);
if (ret) { if (ret) {
D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); jffs2_dbg(1, "%s(): Write failed for block at %08x: error %d\n",
__func__, jeb->offset, ret);
return ret; return ret;
} }
return 1; return 1;
...@@ -1155,7 +1162,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) ...@@ -1155,7 +1162,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
return -EINVAL; return -EINVAL;
} }
D1(printk(KERN_DEBUG "JFFS2 using OOB on NAND\n")); jffs2_dbg(1, "JFFS2 using OOB on NAND\n");
c->oobavail = oinfo->oobavail; c->oobavail = oinfo->oobavail;
......
...@@ -36,7 +36,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -36,7 +36,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
f->inocache->state = INO_STATE_PRESENT; f->inocache->state = INO_STATE_PRESENT;
jffs2_add_ino_cache(c, f->inocache); jffs2_add_ino_cache(c, f->inocache);
D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); jffs2_dbg(1, "%s(): Assigned ino# %d\n", __func__, f->inocache->ino);
ri->ino = cpu_to_je32(f->inocache->ino); ri->ino = cpu_to_je32(f->inocache->ino);
ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
...@@ -95,9 +95,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -95,9 +95,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
BUG_ON(!retried); BUG_ON(!retried);
D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " jffs2_dbg(1, "%s(): dnode_version %d, highest version %d -> updating dnode\n",
"highest version %d -> updating dnode\n", __func__,
je32_to_cpu(ri->version), f->highest_version)); je32_to_cpu(ri->version), f->highest_version);
ri->version = cpu_to_je32(++f->highest_version); ri->version = cpu_to_je32(++f->highest_version);
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
} }
...@@ -127,7 +127,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -127,7 +127,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
retried = 1; retried = 1;
D1(printk(KERN_DEBUG "Retrying failed write.\n")); jffs2_dbg(1, "Retrying failed write.\n");
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
...@@ -147,14 +147,16 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -147,14 +147,16 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
if (!ret) { if (!ret) {
flash_ofs = write_ofs(c); flash_ofs = write_ofs(c);
D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n",
flash_ofs);
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
goto retry; goto retry;
} }
D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n",
ret);
} }
/* Release the full_dnode which is now useless, and return */ /* Release the full_dnode which is now useless, and return */
jffs2_free_full_dnode(fn); jffs2_free_full_dnode(fn);
...@@ -183,10 +185,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -183,10 +185,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
fn->size = je32_to_cpu(ri->dsize); fn->size = je32_to_cpu(ri->dsize);
fn->frags = 0; fn->frags = 0;
D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", jffs2_dbg(1, "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize),
je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc),
je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen));
if (retried) { if (retried) {
jffs2_dbg_acct_sanity_check(c,NULL); jffs2_dbg_acct_sanity_check(c,NULL);
...@@ -206,9 +208,10 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -206,9 +208,10 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
int retried = 0; int retried = 0;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", jffs2_dbg(1, "%s(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n",
__func__,
je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),
je32_to_cpu(rd->name_crc))); je32_to_cpu(rd->name_crc));
D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) {
printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n");
...@@ -249,9 +252,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -249,9 +252,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) {
BUG_ON(!retried); BUG_ON(!retried);
D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " jffs2_dbg(1, "%s(): dirent_version %d, highest version %d -> updating dirent\n",
"highest version %d -> updating dirent\n", __func__,
je32_to_cpu(rd->version), f->highest_version)); je32_to_cpu(rd->version), f->highest_version);
rd->version = cpu_to_je32(++f->highest_version); rd->version = cpu_to_je32(++f->highest_version);
fd->version = je32_to_cpu(rd->version); fd->version = je32_to_cpu(rd->version);
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
...@@ -275,7 +278,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -275,7 +278,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
retried = 1; retried = 1;
D1(printk(KERN_DEBUG "Retrying failed write.\n")); jffs2_dbg(1, "Retrying failed write.\n");
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
...@@ -295,12 +298,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -295,12 +298,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
if (!ret) { if (!ret) {
flash_ofs = write_ofs(c); flash_ofs = write_ofs(c);
D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write\n",
flash_ofs);
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
goto retry; goto retry;
} }
D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n",
ret);
} }
/* Release the full_dnode which is now useless, and return */ /* Release the full_dnode which is now useless, and return */
jffs2_free_full_dirent(fd); jffs2_free_full_dirent(fd);
...@@ -333,8 +338,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -333,8 +338,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
int ret = 0; int ret = 0;
uint32_t writtenlen = 0; uint32_t writtenlen = 0;
D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", jffs2_dbg(1, "%s(): Ino #%u, ofs 0x%x, len 0x%x\n",
f->inocache->ino, offset, writelen)); __func__, f->inocache->ino, offset, writelen);
while(writelen) { while(writelen) {
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
...@@ -345,12 +350,13 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -345,12 +350,13 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
int retried = 0; int retried = 0;
retry: retry:
D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); jffs2_dbg(2, "jffs2_commit_write() loop: 0x%x to write to 0x%x\n",
writelen, offset);
ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN,
&alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret);
break; break;
} }
mutex_lock(&f->sem); mutex_lock(&f->sem);
...@@ -386,7 +392,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -386,7 +392,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
if (!retried) { if (!retried) {
/* Write error to be retried */ /* Write error to be retried */
retried = 1; retried = 1;
D1(printk(KERN_DEBUG "Retrying node write in jffs2_write_inode_range()\n")); jffs2_dbg(1, "Retrying node write in jffs2_write_inode_range()\n");
goto retry; goto retry;
} }
break; break;
...@@ -399,7 +405,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -399,7 +405,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
} }
if (ret) { if (ret) {
/* Eep */ /* Eep */
D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", ret)); jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n",
ret);
jffs2_mark_node_obsolete(c, fn->raw); jffs2_mark_node_obsolete(c, fn->raw);
jffs2_free_full_dnode(fn); jffs2_free_full_dnode(fn);
...@@ -414,7 +421,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, ...@@ -414,7 +421,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
ret = -EIO; ret = -EIO;
break; break;
} }
D1(printk(KERN_DEBUG "increasing writtenlen by %d\n", datalen)); jffs2_dbg(1, "increasing writtenlen by %d\n", datalen);
writtenlen += datalen; writtenlen += datalen;
offset += datalen; offset += datalen;
writelen -= datalen; writelen -= datalen;
...@@ -439,7 +446,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, ...@@ -439,7 +446,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
*/ */
ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
JFFS2_SUMMARY_INODE_SIZE); JFFS2_SUMMARY_INODE_SIZE);
D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); jffs2_dbg(1, "%s(): reserved 0x%x bytes\n", __func__, alloclen);
if (ret) if (ret)
return ret; return ret;
...@@ -450,11 +457,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, ...@@ -450,11 +457,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n", jffs2_dbg(1, "jffs2_do_create created file with mode 0x%x\n",
jemode_to_cpu(ri->mode))); jemode_to_cpu(ri->mode));
if (IS_ERR(fn)) { if (IS_ERR(fn)) {
D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); jffs2_dbg(1, "jffs2_write_dnode() failed\n");
/* Eeek. Wave bye bye */ /* Eeek. Wave bye bye */
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
...@@ -480,7 +487,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, ...@@ -480,7 +487,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
if (ret) { if (ret) {
/* Eep. */ /* Eep. */
D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); jffs2_dbg(1, "jffs2_reserve_space() for dirent failed\n");
return ret; return ret;
} }
...@@ -597,8 +604,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, ...@@ -597,8 +604,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
!memcmp(fd->name, name, namelen) && !memcmp(fd->name, name, namelen) &&
!fd->name[namelen]) { !fd->name[namelen]) {
D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", jffs2_dbg(1, "Marking old dirent node (ino #%u) @%08x obsolete\n",
fd->ino, ref_offset(fd->raw))); fd->ino, ref_offset(fd->raw));
jffs2_mark_node_obsolete(c, fd->raw); jffs2_mark_node_obsolete(c, fd->raw);
/* We don't want to remove it from the list immediately, /* We don't want to remove it from the list immediately,
because that screws up getdents()/seek() semantics even because that screws up getdents()/seek() semantics even
...@@ -630,8 +637,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, ...@@ -630,8 +637,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n",
dead_f->inocache->ino, fd->name, fd->ino); dead_f->inocache->ino, fd->name, fd->ino);
} else { } else {
D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", jffs2_dbg(1, "Removing deletion dirent for \"%s\" from dir ino #%u\n",
fd->name, dead_f->inocache->ino)); fd->name,
dead_f->inocache->ino);
} }
if (fd->raw) if (fd->raw)
jffs2_mark_node_obsolete(c, fd->raw); jffs2_mark_node_obsolete(c, fd->raw);
......
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