mtd/fs/jffs2 file.c,1.58.2.2,1.58.2.3

David Woodhouse dwmw2 at infradead.org
Mon Oct 7 08:25:58 EDT 2002


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

Modified Files:
      Tag: jffs2-2_4-branch
	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.58.2.2
retrieving revision 1.58.2.3
diff -u -r1.58.2.2 -r1.58.2.3
--- file.c	15 Jul 2002 10:57:52 -0000	1.58.2.2
+++ file.c	7 Oct 2002 12:25:55 -0000	1.58.2.3
@@ -394,10 +394,10 @@
 	}
 	
 
-	/* Read in the page if it wasn't already present */
-	if (!Page_Uptodate(pg) && (start || end < PAGE_SIZE))
+	/* Read in the page if it wasn't already present, unless it's a whole page */
+	if (!Page_Uptodate(pg) && (start || end < PAGE_CACHE_SIZE))
 		ret = jffs2_do_readpage_nolock(inode, pg);
-	D1(printk(KERN_DEBUG "end prepare_write(). nrpages %ld\n", inode->i_mapping->nrpages));
+	D1(printk(KERN_DEBUG "end prepare_write(). pg->flags %lx\n", pg->flags));
 	up(&f->sem);
 	return ret;
 }
@@ -417,7 +417,15 @@
 	int ret = 0;
 	ssize_t writtenlen = 0;
 
-	D1(printk(KERN_DEBUG "jffs2_commit_write(): ino #%lu, page at 0x%lx, range %d-%d, nrpages %ld\n", inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end, filp->f_dentry->d_inode->i_mapping->nrpages));
+	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();
 	if (!ri)





More information about the linux-mtd-cvs mailing list