--- ./fs/jffs2/erase.c.orig 2006-08-07 17:21:34 +0200 +++ ./fs/jffs2/erase.c 2006-08-07 17:22:25 +0200 @@ -277,7 +277,7 @@ printk("\n"); }); - if (ic->nodes == (void *)ic) + if (ic->nodes == (void *)ic && ic->nlink == 0) jffs2_del_ino_cache(c, ic); } @@ -311,6 +311,7 @@ marker_ref = jffs2_alloc_raw_node_ref(); if (!marker_ref) { printk(KERN_WARNING "Failed to allocate raw node ref for clean marker\n"); + refile: /* Stick it back on the list from whence it came and come back later */ jffs2_erase_pending_trigger(c); spin_lock(&c->erase_completion_lock); @@ -322,6 +323,7 @@ ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!ebuf) { printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Assuming it worked\n", jeb->offset); + goto refile; } else { uint32_t ofs = jeb->offset; @@ -408,11 +410,13 @@ if (ret) { printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", jeb->offset, ret); + jffs2_free_raw_node_ref(marker_ref); goto bad2; } if (retlen != sizeof(marker)) { printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", jeb->offset, sizeof(marker), retlen); + jffs2_free_raw_node_ref(marker_ref); goto bad2; }