diff options
| -rw-r--r-- | fs/jffs2/wbuf.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 676b83410f8c..404b547c6cf4 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
| @@ -481,11 +481,11 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
| 481 | return ret; | 481 | return ret; |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | spin_lock(&c->erase_completion_lock); | ||
| 485 | |||
| 486 | /* Adjust free size of the block if we padded. */ | 484 | /* Adjust free size of the block if we padded. */ |
| 487 | if (pad) { | 485 | if (pad) { |
| 488 | 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; | ||
| 489 | 489 | ||
| 490 | jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; | 490 | jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; |
| 491 | 491 | ||
| @@ -495,18 +495,29 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
| 495 | /* 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 |
| 496 | 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, |
| 497 | something screwed up */ | 497 | something screwed up */ |
| 498 | if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { | 498 | if (jeb->free_size < waste) { |
| 499 | 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", |
| 500 | c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len); | 500 | c->wbuf_ofs, c->wbuf_len, waste); |
| 501 | 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", |
| 502 | jeb->offset, jeb->free_size); | 502 | jeb->offset, jeb->free_size); |
| 503 | BUG(); | 503 | BUG(); |
| 504 | } | 504 | } |
| 505 | jeb->free_size -= (c->wbuf_pagesize - c->wbuf_len); | 505 | ref = jffs2_alloc_raw_node_ref(); |
| 506 | c->free_size -= (c->wbuf_pagesize - c->wbuf_len); | 506 | if (!ref) |
| 507 | jeb->wasted_size += (c->wbuf_pagesize - c->wbuf_len); | 507 | return -ENOMEM; |
| 508 | c->wasted_size += (c->wbuf_pagesize - c->wbuf_len); | 508 | ref->flash_offset = c->wbuf_ofs + c->wbuf_len; |
| 509 | } | 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); | ||
| 510 | 521 | ||
| 511 | /* Stick any now-obsoleted blocks on the erase_pending_list */ | 522 | /* Stick any now-obsoleted blocks on the erase_pending_list */ |
| 512 | jffs2_refile_wbuf_blocks(c); | 523 | jffs2_refile_wbuf_blocks(c); |
