* [PATCH v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
@ 2025-09-24 7:43 ` Yunji Kang
0 siblings, 0 replies; 6+ messages in thread
From: Yunji Kang @ 2025-09-24 7:43 UTC (permalink / raw)
To: jaegeuk, chao
Cc: linux-f2fs-devel, linux-kernel, Yunji Kang, Sungjong Seo,
Sunmin Jeong
In f2fs_precache_extents(), For large files, It requires reading many
node blocks. Instead of reading each node block with synchronous I/O,
this patch applies readahead so that node blocks can be fetched in
advance.
It reduces the overhead of repeated sync reads and improves efficiency
when precaching extents of large files.
I created a file with the same largest extent and executed the test.
For this experiment, I set the file's largest extent with an offset of 0
and a size of 1GB. I configured the remaining area with 100MB extents.
5GB test file:
dd if=/dev/urandom of=test1 bs=1m count=5120
cp test1 test2
fsync test1
dd if=test1 of=test2 bs=1m skip=1024 seek=1024 count=100 conv=notrunc
dd if=test1 of=test2 bs=1m skip=1224 seek=1224 count=100 conv=notrunc
...
dd if=test1 of=test2 bs=1m skip=5024 seek=5024 count=100 conv=notrunc
reboot
I also created 10GB and 20GB files with large extents using the same
method.
ioctl(F2FS_IOC_PRECACHE_EXTENTS) test results are as follows:
+-----------+---------+---------+-----------+
| File size | Before | After | Reduction |
+-----------+---------+---------+-----------+
| 5GB | 101.8ms | 37.0ms | 72.1% |
| 10GB | 222.9ms | 56.0ms | 74.9% |
| 20GB | 446.2ms | 116.4ms | 73.9% |
+-----------+---------+---------+-----------+
Tested on a 256GB mobile device with an SM8750 chipset.
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
Signed-off-by: Yunji Kang <yunji0.kang@samsung.com>
---
v2:
- Modify the readahead condition check routine for better code
readability.
- Update the title from 'node block' to 'node blocks'.
v3:
- Bug fix to allow more node pages to be readahead.
- Updated with test results.
v4:
- Removed a specific condition for precache,
as using the existing mode (LOOKUP_NODE_RA) is sufficient.
fs/f2fs/data.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7961e0ddfca3..a20a99d7ba5b 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1572,6 +1572,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
pgofs = (pgoff_t)map->m_lblk;
end = pgofs + maxblocks;
+ if (flag == F2FS_GET_BLOCK_PRECACHE)
+ mode = LOOKUP_NODE_RA;
+
next_dnode:
if (map->m_may_create) {
if (f2fs_lfs_mode(sbi))
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [f2fs-dev] [PATCH v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
2025-09-24 7:43 ` Yunji Kang
@ 2025-09-24 7:58 ` Chao Yu
-1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-09-24 7:58 UTC (permalink / raw)
To: Yunji Kang, jaegeuk; +Cc: linux-kernel, Sungjong Seo, linux-f2fs-devel
On 9/24/25 15:43, Yunji Kang wrote:
> In f2fs_precache_extents(), For large files, It requires reading many
> node blocks. Instead of reading each node block with synchronous I/O,
> this patch applies readahead so that node blocks can be fetched in
> advance.
>
> It reduces the overhead of repeated sync reads and improves efficiency
> when precaching extents of large files.
>
> I created a file with the same largest extent and executed the test.
> For this experiment, I set the file's largest extent with an offset of 0
> and a size of 1GB. I configured the remaining area with 100MB extents.
>
> 5GB test file:
> dd if=/dev/urandom of=test1 bs=1m count=5120
> cp test1 test2
> fsync test1
> dd if=test1 of=test2 bs=1m skip=1024 seek=1024 count=100 conv=notrunc
> dd if=test1 of=test2 bs=1m skip=1224 seek=1224 count=100 conv=notrunc
> ...
> dd if=test1 of=test2 bs=1m skip=5024 seek=5024 count=100 conv=notrunc
> reboot
>
> I also created 10GB and 20GB files with large extents using the same
> method.
>
> ioctl(F2FS_IOC_PRECACHE_EXTENTS) test results are as follows:
> +-----------+---------+---------+-----------+
> | File size | Before | After | Reduction |
> +-----------+---------+---------+-----------+
> | 5GB | 101.8ms | 37.0ms | 72.1% |
> | 10GB | 222.9ms | 56.0ms | 74.9% |
> | 20GB | 446.2ms | 116.4ms | 73.9% |
> +-----------+---------+---------+-----------+
> Tested on a 256GB mobile device with an SM8750 chipset.
>
> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
> Signed-off-by: Yunji Kang <yunji0.kang@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
@ 2025-09-24 7:58 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2025-09-24 7:58 UTC (permalink / raw)
To: Yunji Kang, jaegeuk
Cc: chao, linux-f2fs-devel, linux-kernel, Sungjong Seo, Sunmin Jeong
On 9/24/25 15:43, Yunji Kang wrote:
> In f2fs_precache_extents(), For large files, It requires reading many
> node blocks. Instead of reading each node block with synchronous I/O,
> this patch applies readahead so that node blocks can be fetched in
> advance.
>
> It reduces the overhead of repeated sync reads and improves efficiency
> when precaching extents of large files.
>
> I created a file with the same largest extent and executed the test.
> For this experiment, I set the file's largest extent with an offset of 0
> and a size of 1GB. I configured the remaining area with 100MB extents.
>
> 5GB test file:
> dd if=/dev/urandom of=test1 bs=1m count=5120
> cp test1 test2
> fsync test1
> dd if=test1 of=test2 bs=1m skip=1024 seek=1024 count=100 conv=notrunc
> dd if=test1 of=test2 bs=1m skip=1224 seek=1224 count=100 conv=notrunc
> ...
> dd if=test1 of=test2 bs=1m skip=5024 seek=5024 count=100 conv=notrunc
> reboot
>
> I also created 10GB and 20GB files with large extents using the same
> method.
>
> ioctl(F2FS_IOC_PRECACHE_EXTENTS) test results are as follows:
> +-----------+---------+---------+-----------+
> | File size | Before | After | Reduction |
> +-----------+---------+---------+-----------+
> | 5GB | 101.8ms | 37.0ms | 72.1% |
> | 10GB | 222.9ms | 56.0ms | 74.9% |
> | 20GB | 446.2ms | 116.4ms | 73.9% |
> +-----------+---------+---------+-----------+
> Tested on a 256GB mobile device with an SM8750 chipset.
>
> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
> Signed-off-by: Yunji Kang <yunji0.kang@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
2025-09-24 7:43 ` Yunji Kang
@ 2025-09-29 22:30 ` patchwork-bot+f2fs
-1 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2025-09-29 22:30 UTC (permalink / raw)
To: Yunji Kang; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel, sj1557.seo
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Wed, 24 Sep 2025 16:43:58 +0900 you wrote:
> In f2fs_precache_extents(), For large files, It requires reading many
> node blocks. Instead of reading each node block with synchronous I/O,
> this patch applies readahead so that node blocks can be fetched in
> advance.
>
> It reduces the overhead of repeated sync reads and improves efficiency
> when precaching extents of large files.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
https://git.kernel.org/jaegeuk/f2fs/c/72bdca6231a3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [f2fs-dev] [PATCH v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
@ 2025-09-29 22:30 ` patchwork-bot+f2fs
0 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+f2fs @ 2025-09-29 22:30 UTC (permalink / raw)
To: Yunji Kang; +Cc: jaegeuk, chao, sj1557.seo, linux-kernel, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Wed, 24 Sep 2025 16:43:58 +0900 you wrote:
> In f2fs_precache_extents(), For large files, It requires reading many
> node blocks. Instead of reading each node block with synchronous I/O,
> this patch applies readahead so that node blocks can be fetched in
> advance.
>
> It reduces the overhead of repeated sync reads and improves efficiency
> when precaching extents of large files.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v4] f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode
https://git.kernel.org/jaegeuk/f2fs/c/72bdca6231a3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread