Skip to content

Commit 351bc76

Browse files
Yohan JoungJaegeuk Kim
authored andcommitted
f2fs: optimize f2fs DIO overwrites
this is unnecessary when we know we are overwriting already allocated blocks and the overhead of starting a transaction can be significant especially for multithreaded workloads doing small writes. Signed-off-by: Yohan Joung <yohan.joung@sk.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent f098aeb commit 351bc76

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

fs/f2fs/data.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4181,7 +4181,13 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
41814181
map.m_next_pgofs = &next_pgofs;
41824182
map.m_seg_type = f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
41834183
inode->i_write_hint);
4184-
if (flags & IOMAP_WRITE)
4184+
4185+
/*
4186+
* If the blocks being overwritten are already allocated,
4187+
* f2fs_map_lock and f2fs_balance_fs are not necessary.
4188+
*/
4189+
if ((flags & IOMAP_WRITE) &&
4190+
!f2fs_overwrite_io(inode, offset, length))
41854191
map.m_may_create = true;
41864192

41874193
err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO);

0 commit comments

Comments
 (0)