[JFFS2] Set i_blocks when truncating files

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Feb 29 12:59:01 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b28ba9fa0154f78f3d36f5ae9a42f7bb01663cca
Commit:     b28ba9fa0154f78f3d36f5ae9a42f7bb01663cca
Parent:     66a10506d632051e1153e2555f4b2c820d427f64
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Mon Feb 25 15:20:50 2008 +0000
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Mon Feb 25 15:20:50 2008 +0000

    [JFFS2] Set i_blocks when truncating files
    
    Addresses OLPC trac #6480
    
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 fs/jffs2/fs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index e26ea78..3f49562 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -149,6 +149,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
 		jffs2_add_full_dnode_to_inode(c, f, new_metadata);
 		inode->i_size = iattr->ia_size;
+		inode->i_blocks = (inode->i_size + 511) >> 9;
 		f->metadata = NULL;
 	} else {
 		f->metadata = new_metadata;
@@ -167,8 +168,10 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	   We are protected from a simultaneous write() extending i_size
 	   back past iattr->ia_size, because do_truncate() holds the
 	   generic inode semaphore. */
-	if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
-		vmtruncate(inode, iattr->ia_size);
+	if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size) {
+		vmtruncate(inode, iattr->ia_size);	
+		inode->i_blocks = (inode->i_size + 511) >> 9;
+	}	
 
 	return 0;
 }



More information about the linux-mtd-cvs mailing list