mtd/fs/jffs3 wbuf.c,3.13,3.14

hammache at infradead.org hammache at infradead.org
Sat Feb 5 13:23:41 EST 2005


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

Modified Files:
	wbuf.c 
Log Message:
Prevent deadlock when checking erased block for
space allocation during wbuf recovery.



Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/wbuf.c,v
retrieving revision 3.13
retrieving revision 3.14
diff -u -r3.13 -r3.14
--- wbuf.c	2 Feb 2005 22:13:17 -0000	3.13
+++ wbuf.c	5 Feb 2005 18:23:38 -0000	3.14
@@ -855,7 +855,6 @@
 
 	/* Read flash */
 	if (!jffs3_can_mark_obsolete(c)) {
-		down_read(&c->wbuf_sem);
 
 		if (jffs3_cleanmarker_oob(c))
 			ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf, NULL, c->oobinfo);
@@ -881,11 +880,16 @@
 
 	/* if no writebuffer available or write buffer empty, return */
 	if (!c->wbuf_pagesize || !c->wbuf_len)
-		goto exit;
+		return ret;
 
 	/* if we read in a different block, return */
 	if ( (ofs & ~(c->sector_size-1)) != (c->wbuf_ofs & ~(c->sector_size-1)) )
-		goto exit;
+		return ret;
+
+	/* Lock only if we have reason to believe wbuf contains relevant data,
+	   so that checking an erased block during wbuf recovery space allocation
+	   does not deadlock. */
+	down_read(&c->wbuf_sem);
 
 	if (ofs >= c->wbuf_ofs) {
 		owbf = (ofs - c->wbuf_ofs);	/* offset in write buffer */





More information about the linux-mtd-cvs mailing list