UPSTREAM: 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.

Change-Id: Iee83041af61b6f8ec7dca2ce9fbb76e0cf07a696
Signed-off-by: Yohan Joung <yohan.joung@sk.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 351bc761338d9be29065c2b99e603bab336792b7)
This commit is contained in:
Yohan Joung
2025-03-17 22:36:11 +09:00
committed by Carlos Llamas
parent 5f93a67a7b
commit eb1d416506
+7 -1
View File
@@ -4203,7 +4203,13 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
map.m_next_pgofs = &next_pgofs;
map.m_seg_type = f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
inode->i_write_hint);
if (flags & IOMAP_WRITE)
/*
* If the blocks being overwritten are already allocated,
* f2fs_map_lock and f2fs_balance_fs are not necessary.
*/
if ((flags & IOMAP_WRITE) &&
!f2fs_overwrite_io(inode, offset, length))
map.m_may_create = true;
err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO);