aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/wbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r--fs/jffs2/wbuf.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 4cebf0e57c46..404b547c6cf4 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -312,11 +312,9 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
312 return; 312 return;
313 313
314 raw2->flash_offset = ofs | REF_OBSOLETE; 314 raw2->flash_offset = ofs | REF_OBSOLETE;
315 raw2->__totlen = ref_totlen(c, jeb, *first_raw);
316 raw2->next_phys = NULL;
317 raw2->next_in_ino = NULL; 315 raw2->next_in_ino = NULL;
318 316
319 jffs2_add_physical_node_ref(c, raw2); 317 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw));
320 } 318 }
321 return; 319 return;
322 } 320 }
@@ -483,11 +481,11 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
483 return ret; 481 return ret;
484 } 482 }
485 483
486 spin_lock(&c->erase_completion_lock);
487
488 /* Adjust free size of the block if we padded. */ 484 /* Adjust free size of the block if we padded. */
489 if (pad) { 485 if (pad) {
490 struct jffs2_eraseblock *jeb; 486 struct jffs2_eraseblock *jeb;
487 struct jffs2_raw_node_ref *ref;
488 uint32_t waste = c->wbuf_pagesize - c->wbuf_len;
491 489
492 jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; 490 jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
493 491
@@ -497,18 +495,29 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
497 /* wbuf_pagesize - wbuf_len is the amount of space that's to be 495 /* wbuf_pagesize - wbuf_len is the amount of space that's to be
498 padded. If there is less free space in the block than that, 496 padded. If there is less free space in the block than that,
499 something screwed up */ 497 something screwed up */
500 if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { 498 if (jeb->free_size < waste) {
501 printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", 499 printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
502 c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len); 500 c->wbuf_ofs, c->wbuf_len, waste);
503 printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", 501 printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
504 jeb->offset, jeb->free_size); 502 jeb->offset, jeb->free_size);
505 BUG(); 503 BUG();
506 } 504 }
507 jeb->free_size -= (c->wbuf_pagesize - c->wbuf_len); 505 ref = jffs2_alloc_raw_node_ref();
508 c->free_size -= (c->wbuf_pagesize - c->wbuf_len); 506 if (!ref)
509 jeb->wasted_size += (c->wbuf_pagesize - c->wbuf_len); 507 return -ENOMEM;
510 c->wasted_size += (c->wbuf_pagesize - c->wbuf_len); 508 ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
511 } 509 ref->flash_offset |= REF_OBSOLETE;
510
511 spin_lock(&c->erase_completion_lock);
512
513 jffs2_link_node_ref(c, jeb, ref, waste);
514 /* FIXME: that made it count as dirty. Convert to wasted */
515 jeb->dirty_size -= waste;
516 c->dirty_size -= waste;
517 jeb->wasted_size += waste;
518 c->wasted_size += waste;
519 } else
520 spin_lock(&c->erase_completion_lock);
512 521
513 /* Stick any now-obsoleted blocks on the erase_pending_list */ 522 /* Stick any now-obsoleted blocks on the erase_pending_list */
514 jffs2_refile_wbuf_blocks(c); 523 jffs2_refile_wbuf_blocks(c);