mtd/fs/jffs2 file.c,1.78,1.79

David Woodhouse dwmw2 at infradead.org
Mon Oct 7 08:41:19 EDT 2002


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

Modified Files:
	file.c 
Log Message:
Fix deadlock if we need to GC from the page for which commit_write() was called, and we were writing the whole page

Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- file.c	1 Sep 2002 15:47:04 -0000	1.78
+++ file.c	7 Oct 2002 12:41:16 -0000	1.79
@@ -348,10 +348,10 @@
 	}
 	
 
-	/* Read in the page if it wasn't already present */
-	if (!PageUptodate(pg) && (start || end < PAGE_SIZE))
+	/* Read in the page if it wasn't already present, unless it's a whole page */
+	if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE))
 		ret = jffs2_do_readpage_nolock(inode, pg);
-	D1(printk(KERN_DEBUG "end prepare_write()\n"));
+	D1(printk(KERN_DEBUG "end prepare_write(). pg->flags %lx\n", pg->flags));
 	up(&f->sem);
 	return ret;
 }
@@ -368,8 +368,16 @@
 	int ret = 0;
 	uint32_t writtenlen = 0;
 
-	D1(printk(KERN_DEBUG "jffs2_commit_write(): ino #%lu, page at 0x%lx, range %d-%d\n",
-		  inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end));
+	D1(printk(KERN_DEBUG "jffs2_commit_write(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n",
+		  inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end, pg->flags));
+
+	if (!start && end == PAGE_CACHE_SIZE) {
+		/* We need to avoid deadlock with page_cache_read() in
+		   jffs2_garbage_collect_pass(). So we have to mark the
+		   page up to date, to prevent page_cache_read() from 
+		   trying to re-lock it. */
+		SetPageUptodate(pg);
+	}
 
 	ri = jffs2_alloc_raw_inode();
 





More information about the linux-mtd-cvs mailing list