Skip to content

Commit

Permalink
[JFFS2] Set i_blocks when truncating files
Browse files Browse the repository at this point in the history
Addresses OLPC trac #6480

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
David Woodhouse committed Feb 25, 2008
1 parent 66a1050 commit b28ba9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit b28ba9f

Please sign in to comment.