[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jffs_prepare_write() fails to ensure page is uptodate.




dwmw2@xxxxxxx.org said:
> Can people sanity-check and test this before I commit it to the 2.4
> branch  and send it to Alan/Linus? 

Let's try the version which doesn't UnlockPage() in jffs_prepare_write(). 

The interesting case here, for those who are avidly testing it, is where we 
write to a page which wasn't already present in the page cache - 
previously, prepare_write() wouldn't bother to bring in the original data, 
so the part of the page which the write didn't cover would be crap.

Index: inode-v23.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v23.c,v
retrieving revision 1.58
retrieving revision 1.60
diff -u -r1.58 -r1.60
--- inode-v23.c	2001/01/11 00:10:21	1.58
+++ inode-v23.c	2001/02/10 21:19:53	1.60
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * $Id: inode-v23.c,v 1.58 2001/01/11 00:10:21 dwmw2 Exp $
+ * $Id: inode-v23.c,v 1.60 2001/02/10 21:19:53 dwmw2 Exp $
  *
  *
  * Ported to Linux 2.3.x and MTD:
@@ -714,7 +714,7 @@
 
 /* Try to read a page of data from a file.  */
 static int
-jffs_readpage(struct file *file, struct page *page)
+jffs_do_readpage_nolock(struct file *file, struct page *page)
 {
 	void *buf;
 	unsigned long read_len;
@@ -765,15 +765,19 @@
 	}
 	flush_dcache_page(page);
 	
-	UnlockPage(page);
-	
 	put_page(page);
 	
 	D3(printk("jffs_readpage(): Leaving...\n"));
 	
 	return result;
-} /* jffs_readpage()  */
+} /* jffs_do_readpage_nolock()  */
 
+static int jffs_readpage(struct file *file, struct page *page)
+{
+	int ret = jffs_do_readpage_nolock(file, page);
+	UnlockPage(page);
+	return ret;
+}
 
 /* Create a new directory.  */
 static int
@@ -1481,9 +1485,13 @@
 jffs_prepare_write(struct file *filp, struct page *page,
                   unsigned from, unsigned to)
 {
-       /* FIXME: we should detect some error conditions here */
+	/* FIXME: we should detect some error conditions here */
+	
+	/* Bugger that. We should make sure the page is uptodate */
+	if (!Page_Uptodate(page) && (from || to < PAGE_CACHE_SIZE))
+		return jffs_do_readpage_nolock(filp, page);
 
-       return 0;
+	return 0;
 } /* jffs_prepare_write() */
 
 static ssize_t


--
dwmw2



To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com