mtd/fs/jffs2 file.c,1.58.2.4,1.58.2.5

David Woodhouse dwmw2 at infradead.org
Fri Nov 8 17:34:25 EST 2002


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

Modified Files:
      Tag: jffs2-2_4-branch
	file.c 
Log Message:
fix lock ordering fuckup


Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.58.2.4
retrieving revision 1.58.2.5
diff -u -r1.58.2.4 -r1.58.2.5
--- file.c	8 Nov 2002 17:33:52 -0000	1.58.2.4
+++ file.c	8 Nov 2002 22:34:22 -0000	1.58.2.5
@@ -340,7 +340,6 @@
 	__u32 pageofs = pg->index << PAGE_CACHE_SHIFT;
 	int ret = 0;
 
-	down(&f->sem);
 	D1(printk(KERN_DEBUG "jffs2_prepare_write() nrpages %ld\n", inode->i_mapping->nrpages));
 
 	if (pageofs > inode->i_size) {
@@ -354,10 +353,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 = JFFS2_MAGIC_BITMASK;
@@ -400,14 +399,17 @@
 			return ret;
 		}
 		inode->i_size = pageofs;
+		up(&f->sem);
 	}
 	
 
 	/* 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))
+	if (!Page_Uptodate(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