aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/wbuf.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:25:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:25:48 -0400
commit7e97b28309edc5669ced2bb1371704e8f8d084e3 (patch)
tree9605694b00b4233a730ad86ea6d395cf59efc905 /fs/jffs2/wbuf.c
parent5421d059068341b3f21df1a21c2ba9175e55ebef (diff)
parent3887ed5231fb6f339f36c3a0297c996cd1a1dad9 (diff)
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (82 commits) [MTD] m25p80: Add Support for ATMEL AT25DF641 64-Megabit SPI Flash [MTD] m25p80: add FAST_READ access support to M25Pxx [MTD] [NAND] bf5xx_nand: Avoid crash if bfin_mac is installed. [MTD] [NAND] at91_nand: control NCE signal [MTD] [NAND] AT91 hardware ECC compile fix for at91sam9263 / at91sam9260 [MTD] [NAND] Hardware ECC controller on at91sam9263 / at91sam9260 [JFFS2] Introduce dbg_readinode2 log level, use it to shut read_dnode() up [JFFS2] Fix jffs2_reserve_space() when all blocks are pending erasure. [JFFS2] Add erase_checking_list to hold blocks being marked. UBI: add a message [JFFS2] Return values of jffs2_block_check_erase error paths [MTD] Clean up AR7 partition map support [MTD] [NOR] Fix Intel CFI driver for collie flash [JFFS2] Finally remove redundant ref->__totlen field. [JFFS2] Honour TEST_TOTLEN macro in debugging code. ref->__totlen is going! [JFFS2] Add paranoia debugging for superblock counts [JFFS2] Fix free space leak with in-band cleanmarkers [JFFS2] Self-sufficient #includes in jffs2_fs_i.h: include <linux/mutex.h> [MTD] [NAND] Verify probe by retrying to checking the results match [MTD] [NAND] S3C2410 Allow ECC disable to be specified by the board ...
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r--fs/jffs2/wbuf.c28
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
1244void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) { 1253void 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