diff options
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r-- | fs/jffs2/wbuf.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index d1d4f27464ba..8de52b607678 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -578,8 +578,8 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
578 | if (!jffs2_is_writebuffered(c)) | 578 | if (!jffs2_is_writebuffered(c)) |
579 | return 0; | 579 | return 0; |
580 | 580 | ||
581 | if (!down_trylock(&c->alloc_sem)) { | 581 | if (mutex_trylock(&c->alloc_sem)) { |
582 | up(&c->alloc_sem); | 582 | mutex_unlock(&c->alloc_sem); |
583 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | 583 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); |
584 | BUG(); | 584 | BUG(); |
585 | } | 585 | } |
@@ -702,10 +702,10 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
702 | if (!c->wbuf) | 702 | if (!c->wbuf) |
703 | return 0; | 703 | return 0; |
704 | 704 | ||
705 | down(&c->alloc_sem); | 705 | mutex_lock(&c->alloc_sem); |
706 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { | 706 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { |
707 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); | 707 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); |
708 | up(&c->alloc_sem); | 708 | mutex_unlock(&c->alloc_sem); |
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | 711 | ||
@@ -725,14 +725,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
725 | } else while (old_wbuf_len && | 725 | } else while (old_wbuf_len && |
726 | old_wbuf_ofs == c->wbuf_ofs) { | 726 | old_wbuf_ofs == c->wbuf_ofs) { |
727 | 727 | ||
728 | up(&c->alloc_sem); | 728 | mutex_unlock(&c->alloc_sem); |
729 | 729 | ||
730 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); | 730 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); |
731 | 731 | ||
732 | ret = jffs2_garbage_collect_pass(c); | 732 | ret = jffs2_garbage_collect_pass(c); |
733 | if (ret) { | 733 | if (ret) { |
734 | /* GC failed. Flush it with padding instead */ | 734 | /* GC failed. Flush it with padding instead */ |
735 | down(&c->alloc_sem); | 735 | mutex_lock(&c->alloc_sem); |
736 | down_write(&c->wbuf_sem); | 736 | down_write(&c->wbuf_sem); |
737 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 737 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
738 | /* retry flushing wbuf in case jffs2_wbuf_recover | 738 | /* retry flushing wbuf in case jffs2_wbuf_recover |
@@ -742,12 +742,12 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
742 | up_write(&c->wbuf_sem); | 742 | up_write(&c->wbuf_sem); |
743 | break; | 743 | break; |
744 | } | 744 | } |
745 | down(&c->alloc_sem); | 745 | mutex_lock(&c->alloc_sem); |
746 | } | 746 | } |
747 | 747 | ||
748 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); | 748 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); |
749 | 749 | ||
750 | up(&c->alloc_sem); | 750 | mutex_unlock(&c->alloc_sem); |
751 | return ret; | 751 | return ret; |
752 | } | 752 | } |
753 | 753 | ||
@@ -1236,12 +1236,24 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1236 | if (!c->wbuf) | 1236 | if (!c->wbuf) |
1237 | return -ENOMEM; | 1237 | return -ENOMEM; |
1238 | 1238 | ||
1239 | #ifdef CONFIG_JFFS2_FS_WBUF_VERIFY | ||
1240 | c->wbuf_verify = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | ||
1241 | if (!c->wbuf_verify) { | ||
1242 | kfree(c->oobbuf); | ||
1243 | kfree(c->wbuf); | ||
1244 | return -ENOMEM; | ||
1245 | } | ||
1246 | #endif | ||
1247 | |||
1239 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); | 1248 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); |
1240 | 1249 | ||
1241 | return 0; | 1250 | return 0; |
1242 | } | 1251 | } |
1243 | 1252 | ||
1244 | void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) { | 1253 | void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) { |
1254 | #ifdef CONFIG_JFFS2_FS_WBUF_VERIFY | ||
1255 | kfree(c->wbuf_verify); | ||
1256 | #endif | ||
1245 | kfree(c->wbuf); | 1257 | kfree(c->wbuf); |
1246 | } | 1258 | } |
1247 | 1259 | ||