summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2024-11-04 09:35:51 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-05 14:02:23 +0100
commita10cc033b27685f366e0b7372db7ca3a10e47f4d (patch)
tree29a311e1e66d508bf7c5466fb4137b7dbfb10a10
parentc631207897a9b3d41167ceca58e07f8f94720e42 (diff)
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 <oliver.sang@intel.com> Closes: https://lore.kernel.org/oe-lkp/202409122103.e45aa13b-oliver.sang@intel.com Cc: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/f2fs/data.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9202082a3902..3439f72052ee 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1676,7 +1676,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;