Skip to contentSkip to conversation

f2fs: fix to map blocks correctly for direct write

PATCH Applied Chao Yu 2 participants 2 messages Nov 4, 2024 – Nov 18, 2024 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH v2 1/1 f2fs: fix to map blocks correctly for direct write

f2fs_map_blocks() supports to map continuous holes or preallocated address, we should avoid setting F2FS_MAP_MAPPED for these cases only, otherwise, it may fail f2fs_iomap_begin(), and make direct write fallbacking to use buffered IO and flush, result in performance regression.

Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>

---
v2:
- fix wrong commit tile
- clean up code and comment suggested by Jaegeuk

 fs/f2fs/data.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
index 306b86b0595d..7d1bb9518a40 100644
@@ -1676,7 +1676,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 		/* reserved delalloc block should be mapped for fiemap. */
 		if (blkaddr == NEW_ADDR)
 			map->m_flags |= F2FS_MAP_DELALLOC;
-		if (flag != F2FS_GET_BLOCK_DIO || !is_hole)
+		/* DIO READ and hole case, should not map the blocks. */
+		if (!(flag == F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create))
 			map->m_flags |= F2FS_MAP_MAPPED;
 
 		map->m_pblk = blkaddr;
Signature · 1 line
2.40.1
#1 lore raw
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 6 lines · On Mon, 4 Nov 2024 09:35:51 +0800 you wrote:

f2fs_map_blocks() supports to map continuous holes or preallocated address, we should avoid setting F2FS_MAP_MAPPED for these cases only, otherwise, it may fail f2fs_iomap_begin(), and make direct write fallbacking to use buffered IO and flush, result in performance regression.

Quoted 7 lines
Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>

[...]

Here is the summary with links:
- [f2fs-dev,v2] f2fs: fix to map blocks correctly for direct write

    https://git.kernel.org/jaegeuk/f2fs/c/5dd00ebda337

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html