diff options
| author | Chao Yu <yuchao0@huawei.com> | 2017-10-09 17:55:19 +0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-12-06 16:41:37 +0100 |
| commit | ec44506b9dada04a836630ca0dd52286dce4e2c0 (patch) | |
| tree | 41057663157e328d1ea748ced068b78706f1dc76 /fs/f2fs/data.c | |
| parent | cc7995de59b97a8729c3aa33ab68ac6aadb9b552 (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/data.c')
| -rw-r--r-- | fs/f2fs/data.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 7b6d99041..f45f8a9ce 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1565,8 +1565,11 @@ write: err = do_write_data_page(&fio); } } + + down_write(&F2FS_I(inode)->i_sem); if (F2FS_I(inode)->last_disk_size < psize) F2FS_I(inode)->last_disk_size = psize; + up_write(&F2FS_I(inode)->i_sem); done: if (err && err != -ENOENT) |
