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.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 916c87d3393b..0d7abb260489 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -179,6 +179,9 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
179 unsigned char *buf; 179 unsigned char *buf;
180 uint32_t start, end, ofs, len; 180 uint32_t start, end, ofs, len;
181 181
182 if (jffs2_prealloc_raw_node_refs(c, c->reserved_refs + 1))
183 return;
184
182 spin_lock(&c->erase_completion_lock); 185 spin_lock(&c->erase_completion_lock);
183 186
184 jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; 187 jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
@@ -306,17 +309,9 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
306 printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); 309 printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n");
307 kfree(buf); 310 kfree(buf);
308 311
309 if (retlen) { 312 if (retlen)
310 struct jffs2_raw_node_ref *raw2; 313 jffs2_add_physical_node_ref(c, ofs | REF_OBSOLETE, ref_totlen(c, jeb, *first_raw), NULL);
311
312 raw2 = jffs2_alloc_raw_node_ref();
313 if (!raw2)
314 return;
315
316 raw2->flash_offset = ofs | REF_OBSOLETE;
317 314
318 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
319 }
320 return; 315 return;
321 } 316 }
322 printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs); 317 printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs);
@@ -428,6 +423,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
428 if (!c->wbuf_len) /* already checked c->wbuf above */ 423 if (!c->wbuf_len) /* already checked c->wbuf above */
429 return 0; 424 return 0;
430 425
426 if (jffs2_prealloc_raw_node_refs(c, c->reserved_refs + 1))
427 return -ENOMEM;
428
431 /* claim remaining space on the page 429 /* claim remaining space on the page
432 this happens, if we have a change to a new block, 430 this happens, if we have a change to a new block,
433 or if fsync forces us to flush the writebuffer. 431 or if fsync forces us to flush the writebuffer.
@@ -485,7 +483,6 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
485 /* Adjust free size of the block if we padded. */ 483 /* Adjust free size of the block if we padded. */
486 if (pad) { 484 if (pad) {
487 struct jffs2_eraseblock *jeb; 485 struct jffs2_eraseblock *jeb;
488 struct jffs2_raw_node_ref *ref;
489 uint32_t waste = c->wbuf_pagesize - c->wbuf_len; 486 uint32_t waste = c->wbuf_pagesize - c->wbuf_len;
490 487
491 jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; 488 jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
@@ -503,15 +500,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
503 jeb->offset, jeb->free_size); 500 jeb->offset, jeb->free_size);
504 BUG(); 501 BUG();
505 } 502 }
506 ref = jffs2_alloc_raw_node_ref();
507 if (!ref)
508 return -ENOMEM;
509 ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
510 ref->flash_offset |= REF_OBSOLETE;
511 503
512 spin_lock(&c->erase_completion_lock); 504 spin_lock(&c->erase_completion_lock);
513 505
514 jffs2_link_node_ref(c, jeb, ref, waste, NULL); 506 jffs2_link_node_ref(c, jeb, (c->wbuf_ofs + c->wbuf_len) | REF_OBSOLETE, waste, NULL);
515 /* FIXME: that made it count as dirty. Convert to wasted */ 507 /* FIXME: that made it count as dirty. Convert to wasted */
516 jeb->dirty_size -= waste; 508 jeb->dirty_size -= waste;
517 c->dirty_size -= waste; 509 c->dirty_size -= waste;