diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-09-15 12:02:09 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-09-23 20:10:20 +0200 |
commit | 09db6a2ef8d9ca6da71b5de56097e8b769bef299 (patch) | |
tree | 4d5d42b53c9ada734e44e868c7d9146d165d192a /fs/f2fs | |
parent | f2fs: update i_size when __allocate_data_block (diff) | |
download | linux-09db6a2ef8d9ca6da71b5de56097e8b769bef299.tar.xz linux-09db6a2ef8d9ca6da71b5de56097e8b769bef299.zip |
f2fs: fix to truncate blocks past EOF in ->setattr
By using FALLOC_FL_KEEP_SIZE in ->fallocate of f2fs, we can fallocate block past
EOF without changing i_size of inode. These blocks past EOF will not be
truncated in ->setattr as we truncate them only when change the file size.
We should give a chance to truncate blocks out of filesize in setattr().
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a041c66fd611..a95ba23e3bd3 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -560,15 +560,22 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) if (err) return err; - if ((attr->ia_valid & ATTR_SIZE) && - attr->ia_size != i_size_read(inode)) { + if (attr->ia_valid & ATTR_SIZE) { err = f2fs_convert_inline_data(inode, attr->ia_size, NULL); if (err) return err; - truncate_setsize(inode, attr->ia_size); - f2fs_truncate(inode); - f2fs_balance_fs(F2FS_I_SB(inode)); + if (attr->ia_size != i_size_read(inode)) { + truncate_setsize(inode, attr->ia_size); + f2fs_truncate(inode); + f2fs_balance_fs(F2FS_I_SB(inode)); + } else { + /* + * giving a chance to truncate blocks past EOF which + * are fallocated with FALLOC_FL_KEEP_SIZE. + */ + f2fs_truncate(inode); + } } __setattr_copy(inode, attr); |