aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/erase.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/erase.c')
-rw-r--r--fs/jffs2/erase.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index 41451e8bf361..6a4c0a3685da 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: erase.c,v 1.66 2004/11/16 20:36:11 dwmw2 Exp $ 10 * $Id: erase.c,v 1.76 2005/05/03 15:11:40 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -48,6 +48,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
48#else /* Linux */ 48#else /* Linux */
49 struct erase_info *instr; 49 struct erase_info *instr;
50 50
51 D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#x (range %#x-%#x)\n", jeb->offset, jeb->offset, jeb->offset + c->sector_size));
51 instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); 52 instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL);
52 if (!instr) { 53 if (!instr) {
53 printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); 54 printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
@@ -233,7 +234,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
233 continue; 234 continue;
234 } 235 }
235 236
236 if (((*prev)->flash_offset & ~(c->sector_size -1)) == jeb->offset) { 237 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) {
237 /* It's in the block we're erasing */ 238 /* It's in the block we're erasing */
238 struct jffs2_raw_node_ref *this; 239 struct jffs2_raw_node_ref *this;
239 240
@@ -277,11 +278,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
277 printk("\n"); 278 printk("\n");
278 }); 279 });
279 280
280 if (ic->nodes == (void *)ic) { 281 if (ic->nodes == (void *)ic && ic->nlink == 0)
281 D1(printk(KERN_DEBUG "inocache for ino #%u is all gone now. Freeing\n", ic->ino));
282 jffs2_del_ino_cache(c, ic); 282 jffs2_del_ino_cache(c, ic);
283 jffs2_free_inode_cache(ic);
284 }
285} 283}
286 284
287static void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) 285static void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
@@ -310,7 +308,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
310 int ret; 308 int ret;
311 uint32_t bad_offset; 309 uint32_t bad_offset;
312 310
313 if (!jffs2_cleanmarker_oob(c)) { 311 if ((!jffs2_cleanmarker_oob(c)) && (c->cleanmarker_size > 0)) {
314 marker_ref = jffs2_alloc_raw_node_ref(); 312 marker_ref = jffs2_alloc_raw_node_ref();
315 if (!marker_ref) { 313 if (!marker_ref) {
316 printk(KERN_WARNING "Failed to allocate raw node ref for clean marker\n"); 314 printk(KERN_WARNING "Failed to allocate raw node ref for clean marker\n");
@@ -335,7 +333,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
335 333
336 bad_offset = ofs; 334 bad_offset = ofs;
337 335
338 ret = jffs2_flash_read(c, ofs, readlen, &retlen, ebuf); 336 ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf);
337
339 if (ret) { 338 if (ret) {
340 printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret); 339 printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
341 goto bad; 340 goto bad;
@@ -351,7 +350,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
351 bad_offset += i; 350 bad_offset += i;
352 printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", datum, bad_offset); 351 printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", datum, bad_offset);
353 bad: 352 bad:
354 if (!jffs2_cleanmarker_oob(c)) 353 if ((!jffs2_cleanmarker_oob(c)) && (c->cleanmarker_size > 0))
355 jffs2_free_raw_node_ref(marker_ref); 354 jffs2_free_raw_node_ref(marker_ref);
356 kfree(ebuf); 355 kfree(ebuf);
357 bad2: 356 bad2:
@@ -387,6 +386,13 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
387 jeb->used_size = 0; 386 jeb->used_size = 0;
388 jeb->dirty_size = 0; 387 jeb->dirty_size = 0;
389 jeb->wasted_size = 0; 388 jeb->wasted_size = 0;
389 } else if (c->cleanmarker_size == 0) {
390 jeb->first_node = jeb->last_node = NULL;
391
392 jeb->free_size = c->sector_size;
393 jeb->used_size = 0;
394 jeb->dirty_size = 0;
395 jeb->wasted_size = 0;
390 } else { 396 } else {
391 struct kvec vecs[1]; 397 struct kvec vecs[1];
392 struct jffs2_unknown_node marker = { 398 struct jffs2_unknown_node marker = {