diff options
author | Chao Yu <yuchao0@huawei.com> | 2017-10-09 17:55:19 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-10-26 10:44:12 +0200 |
commit | a0d00fad353d4a315f54fb345aa1c65b3771389b (patch) | |
tree | 65f4c30f4ca73234c64a42ff9a88e02ad0eb45fa /fs/f2fs/file.c | |
parent | ebf7c522fdc2ec2fa0fc2351ef613841f79586e5 (diff) |
f2fs: fix to avoid race when accessing last_disk_size
last_disk_size could be wrong due to concurrently updating, so using
i_sem semaphore to make last_disk_size updating exclusive to fix this
issue.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index cfee75bf88d9..9b93aea5cbeb 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -777,6 +777,10 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) inode->i_mtime = inode->i_ctime = current_time(inode); } + down_write(&F2FS_I(inode)->i_sem); + F2FS_I(inode)->last_disk_size = i_size_read(inode); + up_write(&F2FS_I(inode)->i_sem); + size_changed = true; } |