diff mbox series

[f2fs-dev] f2fs: fix to map blocks correctly for direct read

Message ID 20241031102200.440407-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs: fix to map blocks correctly for direct read | expand

Commit Message

Chao Yu Oct. 31, 2024, 10:22 a.m. UTC
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>
---
 fs/f2fs/data.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jaegeuk Kim Nov. 1, 2024, 1:22 a.m. UTC | #1
On 10/31, Chao Yu 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.

Is this fixing direct write or read?

> 
> 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>
> ---
>  fs/f2fs/data.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 306b86b0595d..38b85160c6bd 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1676,7 +1676,12 @@ 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)
> +		/*
> +		 * f2fs_map_blocks() supports to map continuous holes or
> +		 * preallocated address, don't set F2FS_MAP_MAPPED for these
> +		 * cases only.
> +		 */
> +		if (flag != F2FS_GET_BLOCK_DIO || map->m_may_create || !is_hole)

So, this is adding map->m_may_create, which is for writes?

>  			map->m_flags |= F2FS_MAP_MAPPED;
>  
>  		map->m_pblk = blkaddr;
> -- 
> 2.40.1
Chao Yu Nov. 1, 2024, 1:32 a.m. UTC | #2
On 2024/11/1 9:22, Jaegeuk Kim wrote:
> On 10/31, Chao Yu 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.
> 
> Is this fixing direct write or read?

Direct write.

> 
>>
>> 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>
>> ---
>>   fs/f2fs/data.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>> index 306b86b0595d..38b85160c6bd 100644
>> --- a/fs/f2fs/data.c
>> +++ b/fs/f2fs/data.c
>> @@ -1676,7 +1676,12 @@ 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)
>> +		/*
>> +		 * f2fs_map_blocks() supports to map continuous holes or
>> +		 * preallocated address, don't set F2FS_MAP_MAPPED for these
>> +		 * cases only.
>> +		 */
>> +		if (flag != F2FS_GET_BLOCK_DIO || map->m_may_create || !is_hole)
> 
> So, this is adding map->m_may_create, which is for writes?

map->m_may_create is added for write path, w/o this condition, f2fs_map_blocks()
may missed to tag F2FS_MAP_MAPPED, result in that f2fs_iomap_begin() will return
-ENOTBLK.

Am I missing someting?

Thanks,

> 
>>   			map->m_flags |= F2FS_MAP_MAPPED;
>>   
>>   		map->m_pblk = blkaddr;
>> -- 
>> 2.40.1
diff mbox series

Patch

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 306b86b0595d..38b85160c6bd 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1676,7 +1676,12 @@  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)
+		/*
+		 * f2fs_map_blocks() supports to map continuous holes or
+		 * preallocated address, don't set F2FS_MAP_MAPPED for these
+		 * cases only.
+		 */
+		if (flag != F2FS_GET_BLOCK_DIO || map->m_may_create || !is_hole)
 			map->m_flags |= F2FS_MAP_MAPPED;
 
 		map->m_pblk = blkaddr;