Patchwork [JFFS2] Write buffer offset adjustment for NOR-ECC (Sibley) flash

login
register
mail settings
Submitter Alexander Belyakov
Date Oct. 17, 2008, 3:19 p.m.
Message ID <E1Kqr6f-0005ZX-00.abelyako-mail-ru@f225.mail.ru>
Download mbox | patch
Permalink /patch/4879/
State New, archived
Headers show

Comments

Alexander Belyakov - Oct. 17, 2008, 3:19 p.m.
After choosing new c->nextblock, don't leave the wbuf offset field
occasionally pointing at the start of the next physical eraseblock.
This was causing a BUG() on NOR-ECC (Sibley) flash, where we start
writing after the cleanmarker.

Among other this fix should cover write buffer offset adjustment
after flushing the last page of an eraseblock.


Signed-off-by: Alexander Belyakov <abelyako@googlemail.com>

---

Patch

diff -uNrp a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
--- a/fs/jffs2/nodemgmt.c	2008-08-20 22:11:37.000000000 +0400
+++ b/fs/jffs2/nodemgmt.c	2008-10-17 12:46:53.000000000 +0400
@@ -261,6 +261,10 @@  static int jffs2_find_nextblock(struct j
 
 	jffs2_sum_reset_collected(c->summary); /* reset collected summary */
 
+	/* adjust write buffer offset, else we get a non contiguous write bug */
+	if (!(c->wbuf_ofs % c->sector_size) && !c->wbuf_len)
+		c->wbuf_ofs = 0xffffffff;
+
 	D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset));
 
 	return 0;
diff -uNrp a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
--- a/fs/jffs2/wbuf.c	2008-08-20 22:11:37.000000000 +0400
+++ b/fs/jffs2/wbuf.c	2008-10-17 12:35:45.000000000 +0400
@@ -679,10 +679,7 @@  static int __jffs2_flush_wbuf(struct jff
 
 	memset(c->wbuf,0xff,c->wbuf_pagesize);
 	/* adjust write buffer offset, else we get a non contiguous write bug */
-	if (SECTOR_ADDR(c->wbuf_ofs) == SECTOR_ADDR(c->wbuf_ofs+c->wbuf_pagesize))
-		c->wbuf_ofs += c->wbuf_pagesize;
-	else
-		c->wbuf_ofs = 0xffffffff;
+	c->wbuf_ofs += c->wbuf_pagesize;
 	c->wbuf_len = 0;
 	return 0;
 }