diff options
author | Daeho Jeong <daehojeong@google.com> | 2020-05-27 07:02:31 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-05-28 22:00:43 +0300 |
commit | fd6126484ceaa9d94db196931c10454090f3d677 (patch) | |
tree | cc4ccc4f2118cca281e3a745228cd917b5169f3a /fs/f2fs/file.c | |
parent | 195f406543e555611330b98ea8c21f113a192fc3 (diff) | |
download | linux-fd6126484ceaa9d94db196931c10454090f3d677.tar.xz |
f2fs: protect new segment allocation in expand_inode_data
Found a new segemnt allocation without f2fs_lock_op() in
expand_inode_data(). So, when we do fallocate() for a pinned file
and trigger checkpoint very frequently and simultaneously. F2FS gets
stuck in the below code of do_checkpoint() forever.
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
/* Wait for all dirty meta pages to be submitted for IO */
<= if fallocate() here,
f2fs_wait_on_all_pages(sbi, F2FS_DIRTY_META); <= it'll wait forever.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-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 67fd1c900eb4..dfa1ac2d751a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1658,7 +1658,11 @@ next_alloc: down_write(&sbi->pin_sem); map.m_seg_type = CURSEG_COLD_DATA_PINNED; + + f2fs_lock_op(sbi); f2fs_allocate_new_segments(sbi, CURSEG_COLD_DATA); + f2fs_unlock_op(sbi); + err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO); up_write(&sbi->pin_sem); |