Skip to contentSkip to conversation

f2fs: fix to map blocks correctly for direct read

PATCH Superseded Chao Yu 2 participants 5 messages Oct 31, 2024 – Nov 2, 2024 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

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

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]>
---
 fs/f2fs/data.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/data.c +6 -1
index 306b86b0595d..38b85160c6bd 100644
@@ -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;
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 5 lines · Chao Yu

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?

Quoted 15 lines
Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>
---
 fs/f2fs/data.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 306b86b0595d..38b85160c6bd 100644

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1684

Quoted 10 lines
fs/f2fs/data.c +6 -1
@@ -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?

Quoted 5 lines
fs/f2fs/data.c +0 -0
 			map->m_flags |= F2FS_MAP_MAPPED;
 
 		map->m_pblk = blkaddr;
Signature · 1 line
2.40.1
author maintainer
#2 lore raw
Quoted 8 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

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.

Quoted 20 lines
Quoted 20 lines
Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>
---
  fs/f2fs/data.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -1
index 306b86b0595d..38b85160c6bd 100644
@@ -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)
Quoted 8 lines

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1684

Quoted 6 lines
fs/f2fs/data.c +6 -0
+		/*
+		 * 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,

Quoted 6 lines
Quoted 6 lines
fs/f2fs/data.c +0 -0
  			map->m_flags |= F2FS_MAP_MAPPED;
 
  		map->m_pblk = blkaddr;
Signature · 1 line
2.40.1
maintainer
#3 lore raw
Quoted 11 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

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.

I was confising the patch subject is saying direct read.

Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>
---
  fs/f2fs/data.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -1
index 306b86b0595d..38b85160c6bd 100644
@@ -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)
Quoted 8 lines

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1684

Quoted 6 lines
fs/f2fs/data.c +6 -0
+		/*
+		 * 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?

Quoted 3 lines

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.

Is that something like this?

/* DIO READ and hole case, should not map the blocks. */ if (!(flag == F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create))

Quoted 10 lines

Am I missing someting?

Thanks,

Quoted 5 lines
Quoted 5 lines
fs/f2fs/data.c +0 -0
  			map->m_flags |= F2FS_MAP_MAPPED;
  		map->m_pblk = blkaddr;
Signature · 1 line
2.40.1
author maintainer
#4 lore raw
Quoted 9 lines · Jaegeuk Kim
Quoted 8 lines · Chao Yu
Quoted 7 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

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 5 lines
Quoted 3 lines
Quoted 1 line

Is this fixing direct write or read?

Direct write.

I was confising the patch subject is saying direct read.

Oops, sorry.

Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 18 lines
Fixes 9f0f6bf42714 ("f2fs: support to map continuous holes or preallocated address")
Cc Cyril Hrubis <[email protected]>
---
   fs/f2fs/data.c | 7 ++++++-
   1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 306b86b0595d..38b85160c6bd 100644

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1684

Quoted 10 lines
fs/f2fs/data.c +6 -1
@@ -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?

Quoted 8 lines
Quoted 3 lines

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.

Is that something like this?

/* DIO READ and hole case, should not map the blocks. */ if (!(flag == F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create))

More clear, will update w/ this.

Thanks,

Quoted 11 lines
Quoted 11 lines

Am I missing someting?

Thanks,

Quoted 5 lines
Quoted 5 lines
fs/f2fs/data.c +0 -0
   			map->m_flags |= F2FS_MAP_MAPPED;
   		map->m_pblk = blkaddr;
Signature · 1 line
2.40.1