summaryrefslogtreecommitdiffstats
path: root/fs/jffs2/wbuf.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-21 13:00:54 +0100
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-21 13:00:54 +0100
commit0bcc099d6d1a7b9fa2adf7c19812e4e816915e10 (patch)
tree36f4c8c9c50369577b0b65823c04fcfb85502d98 /fs/jffs2/wbuf.c
parentb64335f2b740d6f5dbf5d3b04af30d407bf599f5 (diff)
downloadlinux-0bcc099d6d1a7b9fa2adf7c19812e4e816915e10.tar.gz
linux-0bcc099d6d1a7b9fa2adf7c19812e4e816915e10.tar.bz2
linux-0bcc099d6d1a7b9fa2adf7c19812e4e816915e10.zip
[JFFS2] File node reference for wasted space when flushing wbuf
Next step in ongoing campaign to file a struct jffs2_raw_node_ref for every piece of dirty space in the system, so that __totlen can be killed off.... Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r--fs/jffs2/wbuf.c29
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)
return ret;
}
- spin_lock(&c->erase_completion_lock);
-
/* Adjust free size of the block if we padded. */
if (pad) {
struct jffs2_eraseblock *jeb;
+ struct jffs2_raw_node_ref *ref;
+ uint32_t waste = c->wbuf_pagesize - c->wbuf_len;
jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
@@ -495,18 +495,29 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
/* 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,
something screwed up */
- if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
+ if (jeb->free_size < waste) {
printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
- c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len);
+ c->wbuf_ofs, c->wbuf_len, waste);
printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
jeb->offset, jeb->free_size);
BUG();
}
- jeb->free_size -= (c->wbuf_pagesize - c->wbuf_len);
- c->free_size -= (c->wbuf_pagesize - c->wbuf_len);
- jeb->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
- c->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
- }
+ ref = jffs2_alloc_raw_node_ref();
+ if (!ref)
+ return -ENOMEM;
+ ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
+ ref->flash_offset |= REF_OBSOLETE;
+
+ spin_lock(&c->erase_completion_lock);
+
+ jffs2_link_node_ref(c, jeb, ref, waste);
+ /* FIXME: that made it count as dirty. Convert to wasted */
+ jeb->dirty_size -= waste;
+ c->dirty_size -= waste;
+ jeb->wasted_size += waste;
+ c->wasted_size += waste;
+ } else
+ spin_lock(&c->erase_completion_lock);
/* Stick any now-obsoleted blocks on the erase_pending_list */
jffs2_refile_wbuf_blocks(c);