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

David Woodhouse dwmw2 at infradead.org
Fri Nov 8 17:43:21 EST 2002


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

Modified Files:
	file.c 
Log Message:
Fix lock ordering fuckup detected by fsx-linux


Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- file.c	7 Oct 2002 12:41:16 -0000	1.79
+++ file.c	8 Nov 2002 22:43:19 -0000	1.80
@@ -282,7 +282,6 @@
 	uint32_t pageofs = pg->index << PAGE_CACHE_SHIFT;
 	int ret = 0;
 
-	down(&f->sem);
 	D1(printk(KERN_DEBUG "jffs2_prepare_write()\n"));
 
 	if (pageofs > inode->i_size) {
@@ -296,10 +295,10 @@
 			  (unsigned int)inode->i_size, pageofs));
 
 		ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, ALLOC_NORMAL);
-		if (ret) {
-			up(&f->sem);
+		if (ret)
 			return ret;
-		}
+
+		down(&f->sem);
 		memset(&ri, 0, sizeof(ri));
 
 		ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -345,14 +344,16 @@
 		}
 		jffs2_complete_reservation(c);
 		inode->i_size = pageofs;
+		up(&f->sem);
 	}
 	
-
 	/* Read in the page if it wasn't already present, unless it's a whole page */
-	if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE))
+	if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE)) {
+		down(&f->sem);
 		ret = jffs2_do_readpage_nolock(inode, pg);
+		up(&f->sem);
+	}
 	D1(printk(KERN_DEBUG "end prepare_write(). pg->flags %lx\n", pg->flags));
-	up(&f->sem);
 	return ret;
 }
 





More information about the linux-mtd-cvs mailing list