From a579a2946e65e87d395c8fda938dcc92962fe505 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 23 May 2011 15:13:02 -0400 Subject: [PATCH] --- yaml --- r: 251744 b: refs/heads/master c: 072bd7ea74d4b60149a33967d29666bbd84e7709 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ext4/inode.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index bc72790d2264..a723be613159 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 28e35e42fb255cbaeee8b9f89643f26fe376374d +refs/heads/master: 072bd7ea74d4b60149a33967d29666bbd84e7709 diff --git a/trunk/fs/ext4/inode.c b/trunk/fs/ext4/inode.c index 6348c1f610c2..d98b033dd4a4 100644 --- a/trunk/fs/ext4/inode.c +++ b/trunk/fs/ext4/inode.c @@ -5309,8 +5309,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE && - (attr->ia_size < inode->i_size || - (ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS)))) { + (attr->ia_size < inode->i_size)) { handle_t *handle; handle = ext4_journal_start(inode, 3); @@ -5344,14 +5343,15 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) goto err_out; } } - /* ext4_truncate will clear the flag */ - if ((ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS))) - ext4_truncate(inode); } - if ((attr->ia_valid & ATTR_SIZE) && - attr->ia_size != i_size_read(inode)) - rc = vmtruncate(inode, attr->ia_size); + if (attr->ia_valid & ATTR_SIZE) { + if (attr->ia_size != i_size_read(inode)) { + truncate_setsize(inode, attr->ia_size); + ext4_truncate(inode); + } else if (ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS)) + ext4_truncate(inode); + } if (!rc) { setattr_copy(inode, attr);