1 ext4: only call ext4_truncate when size <= isize
3 From: Josef Bacik <jbacik@fb.com>
5 At LSF we decided that if we truncate up from isize we shouldn't trim
6 fallocated blocks that were fallocated with KEEP_SIZE and are past the
7 new i_size. This patch fixes ext4 to do this. Thanks,
9 Signed-off-by: Josef Bacik <jbacik@fb.com>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 Reviewed-by: Lukas Czerner <lczerner@redhat.com>
13 fs/ext4/inode.c | 5 ++---
14 1 file changed, 2 insertions(+), 3 deletions(-)
16 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
17 index 0554b0b..92174dd 100644
20 @@ -4640,6 +4640,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
21 int ext4_setattr(struct dentry *dentry, struct iattr *attr)
23 struct inode *inode = d_inode(dentry);
24 + loff_t oldsize = inode->i_size;
27 const unsigned int ia_valid = attr->ia_valid;
28 @@ -4727,8 +4728,6 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
32 - loff_t oldsize = inode->i_size;
34 i_size_write(inode, attr->ia_size);
35 pagecache_isize_extended(inode, oldsize, inode->i_size);
37 @@ -4756,7 +4755,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
38 * We want to call ext4_truncate() even if attr->ia_size ==
39 * inode->i_size for cases like truncation of fallocated space
41 - if (attr->ia_valid & ATTR_SIZE)
42 + if (attr->ia_valid & ATTR_SIZE && attr->ia_size <= oldsize)
50 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
51 the body of a message to majordomo@vger.kernel.org
52 More majordomo info at http://vger.kernel.org/majordomo-info.html