mtd/fs/jffs2 file.c,1.58.2.7,1.58.2.8
David Woodhouse
dwmw2 at infradead.org
Mon Jan 26 07:40:35 EST 2004
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv31478
Modified Files:
Tag: jffs2-2_4-branch
file.c
Log Message:
Potential fix for truncate/readpage race.
Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.58.2.7
retrieving revision 1.58.2.8
diff -u -r1.58.2.7 -r1.58.2.8
--- file.c 2 Nov 2003 13:51:17 -0000 1.58.2.7
+++ file.c 26 Jan 2004 12:40:32 -0000 1.58.2.8
@@ -1,7 +1,7 @@
/*
* JFFS2 -- Journalling Flash File System, Version 2.
*
- * Copyright (C) 2001 Red Hat, Inc.
+ * Copyright (C) 2001-2004 Red Hat, Inc.
*
* Created by David Woodhouse <dwmw2 at cambridge.redhat.com>
*
@@ -197,10 +197,8 @@
old_metadata = f->metadata;
- if (inode->i_size > ri->isize) {
- vmtruncate(inode, ri->isize);
+ if (inode->i_size > ri->isize)
jffs2_truncate_fraglist (c, &f->fraglist, ri->isize);
- }
if (inode->i_size < ri->isize) {
jffs2_add_full_dnode_to_inode(c, f, new_metadata);
@@ -215,6 +213,15 @@
}
jffs2_free_raw_inode(ri);
up(&f->sem);
+
+ /* We have to do the vmtruncate() without f->sem held, since
+ some pages may be locked and waiting for it in readpage().
+ We are protected from a simultaneous write() extending i_size
+ back past iattr->ia_size, because do_truncate() holds the
+ generic inode semaphore. */
+ if (inode->i_size > ri->isize)
+ vmtruncate(inode, ri->isize);
+
return 0;
}
More information about the linux-mtd-cvs
mailing list