551
552 jffs2_dbg_acct_sanity_check_nolock(c, new_jeb);
553 jffs2_dbg_acct_paranoia_check_nolock(c, new_jeb);
554
555 spin_unlock(&c->erase_completion_lock);
556
557 D1(printk(KERN_DEBUG "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", c->wbuf_ofs, c->wbuf_len));
558
559}
560
561
562
563
564
565
566#define NOPAD 0
567#define PAD_NOACCOUNT 1
568#define PAD_ACCOUNTING 2
569
570static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
571{
572 struct jffs2_eraseblock *wbuf_jeb;
573 int ret;
574 size_t retlen;
575
576
577
578 if (!jffs2_is_writebuffered(c))
579 return 0;
580
581 if (mutex_trylock(&c->alloc_sem)) {
582 mutex_unlock(&c->alloc_sem);
583 printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n");
584 BUG();
585 }
586
587 if (!c->wbuf_len)
588 return 0;
589
590 wbuf_jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
591 if (jffs2_prealloc_raw_node_refs(c, wbuf_jeb, c->nextblock->allocated_refs + 1))