Skip to content

Commit fd61264

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
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 <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 195f406 commit fd61264

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/f2fs/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,11 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
16581658

16591659
down_write(&sbi->pin_sem);
16601660
map.m_seg_type = CURSEG_COLD_DATA_PINNED;
1661+
1662+
f2fs_lock_op(sbi);
16611663
f2fs_allocate_new_segments(sbi, CURSEG_COLD_DATA);
1664+
f2fs_unlock_op(sbi);
1665+
16621666
err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO);
16631667
up_write(&sbi->pin_sem);
16641668

0 commit comments

Comments
 (0)