mtd/fs/jffs2 wbuf.c,1.45,1.46

David Woodhouse dwmw2 at infradead.org
Fri Oct 3 12:37:46 EDT 2003


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv4027

Modified Files:
	wbuf.c 
Log Message:
Fix write-out recover case.


Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- wbuf.c	3 Oct 2003 16:17:09 -0000	1.45
+++ wbuf.c	3 Oct 2003 16:37:43 -0000	1.46
@@ -19,7 +19,7 @@
 #include "nodelist.h"
 
 /* For testing write failures */
-/* #define BREAKME */
+//#define BREAKME
 
 /* max. erase failures before we mark a block bad */
 #define MAX_ERASE_FAILURES 	5
@@ -192,8 +192,11 @@
 		}
 
 		/* Do the read... */
-		ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf);
-
+		ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo);
+		if (ret == -EIO && retlen == c->wbuf_ofs - start) {
+			/* ECC recovered */
+			ret = 0;
+		}
 		if (ret || retlen != c->wbuf_ofs - start) {
 			printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n");
 
@@ -230,7 +233,11 @@
 		 the wbuf. Since if we're writing from the wbuf there
 		 won't be more than a wbuf full of data, now will
 		 there? :) */
-		ret = c->mtd->write_ecc(c->mtd, ofs, (end-start)%c->wbuf_pagesize,
+		D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n",
+			  (end-start) - ((end-start)%c->wbuf_pagesize), ofs));
+	  
+		ret = c->mtd->write_ecc(c->mtd, ofs, 
+					(end-start) - ((end-start)%c->wbuf_pagesize),
 					&retlen, buf, NULL, c->oobinfo);
 #ifdef BREAKME
 		static int breakme;




More information about the linux-mtd-cvs mailing list