diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ecac8c5a6f5c..edb7edc99f71 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4456,6 +4456,8 @@ void ext4_truncate(struct inode *inode) | |||
4456 | if (!ext4_can_truncate(inode)) | 4456 | if (!ext4_can_truncate(inode)) |
4457 | return; | 4457 | return; |
4458 | 4458 | ||
4459 | EXT4_I(inode)->i_flags &= ~EXT4_EOFBLOCKS_FL; | ||
4460 | |||
4459 | if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC)) | 4461 | if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC)) |
4460 | ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE); | 4462 | ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE); |
4461 | 4463 | ||
@@ -5305,7 +5307,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
5305 | } | 5307 | } |
5306 | 5308 | ||
5307 | if (S_ISREG(inode->i_mode) && | 5309 | if (S_ISREG(inode->i_mode) && |
5308 | attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) { | 5310 | attr->ia_valid & ATTR_SIZE && |
5311 | (attr->ia_size < inode->i_size || | ||
5312 | (EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL))) { | ||
5309 | handle_t *handle; | 5313 | handle_t *handle; |
5310 | 5314 | ||
5311 | handle = ext4_journal_start(inode, 3); | 5315 | handle = ext4_journal_start(inode, 3); |
@@ -5336,6 +5340,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
5336 | goto err_out; | 5340 | goto err_out; |
5337 | } | 5341 | } |
5338 | } | 5342 | } |
5343 | /* ext4_truncate will clear the flag */ | ||
5344 | if ((EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL)) | ||
5345 | ext4_truncate(inode); | ||
5339 | } | 5346 | } |
5340 | 5347 | ||
5341 | rc = inode_setattr(inode, attr); | 5348 | rc = inode_setattr(inode, attr); |