From: Chao Yu Date: Mon, 4 Nov 2024 01:35:51 +0000 (+0800) Subject: f2fs: fix to map blocks correctly for direct write X-Git-Tag: v6.11.11~295 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90a097f35f5c3e86a4e1a02f1bea9aabe5652b25;p=thirdparty%2Fkernel%2Fstable.git f2fs: fix to map blocks correctly for direct write [ Upstream commit 5dd00ebda337b9295e7027691fa70540da369ff2 ] 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") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202409122103.e45aa13b-oliver.sang@intel.com Cc: Cyril Hrubis Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 5e83ec442f88d..af66edc722e98 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1677,7 +1677,8 @@ next_block: /* 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;