* [PATCH] f2fs: skip inode folio lookup for cached overwrite
@ 2026-05-29 2:29 Wenjie Qi
2026-06-15 10:43 ` Chao Yu
2026-06-15 15:30 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 2 replies; 3+ messages in thread
From: Wenjie Qi @ 2026-05-29 2:29 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, qiwenjie, qwjhust
prepare_write_begin() first gets the inode folio and builds a dnode,
then checks the read extent cache. For an ordinary overwrite of a
non-inline and non-compressed file, an extent-cache hit already gives the
data block address and the following path does not need to allocate or
update any node state.
Check the read extent cache before fetching the inode folio for that
narrow case. Keep the existing paths for inline data, compressed files,
and writes that may extend past EOF, where the helper may need inline
conversion, compression preparation, or block reservation.
This avoids a node-folio lookup in the buffered overwrite fast path when
the mapping is already cached.
In a QEMU/KASAN x86_64 VM, using a small buffered overwrite workload on
an existing 1MiB file, median time improved as follows:
64-byte overwrites: 1724.93 ns/write -> 1560.24 ns/write
256-byte overwrites: 1713.38 ns/write -> 1577.85 ns/write
Function profiling of 20k 64-byte overwrites showed
f2fs_get_inode_folio() calls drop from 20004 to 4.
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
fs/f2fs/data.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index d83a21998ec2..3b32f9b75b77 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3719,6 +3719,11 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
int flag = F2FS_GET_BLOCK_PRE_AIO;
int err = 0;
+ if (!f2fs_has_inline_data(inode) && !f2fs_compressed_file(inode) &&
+ (pos & PAGE_MASK) < i_size_read(inode) &&
+ f2fs_lookup_read_extent_cache_block(inode, index, blk_addr))
+ return 0;
+
/*
* If a whole page is being written and we already preallocated all the
* blocks, then there is no need to get a block address now.
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: skip inode folio lookup for cached overwrite
2026-05-29 2:29 [PATCH] f2fs: skip inode folio lookup for cached overwrite Wenjie Qi
@ 2026-06-15 10:43 ` Chao Yu
2026-06-15 15:30 ` [f2fs-dev] " patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-06-15 10:43 UTC (permalink / raw)
To: Wenjie Qi, jaegeuk; +Cc: chao, linux-f2fs-devel, linux-kernel, qiwenjie
On 5/29/26 10:29, Wenjie Qi wrote:
> prepare_write_begin() first gets the inode folio and builds a dnode,
> then checks the read extent cache. For an ordinary overwrite of a
> non-inline and non-compressed file, an extent-cache hit already gives the
> data block address and the following path does not need to allocate or
> update any node state.
>
> Check the read extent cache before fetching the inode folio for that
> narrow case. Keep the existing paths for inline data, compressed files,
> and writes that may extend past EOF, where the helper may need inline
> conversion, compression preparation, or block reservation.
>
> This avoids a node-folio lookup in the buffered overwrite fast path when
> the mapping is already cached.
>
> In a QEMU/KASAN x86_64 VM, using a small buffered overwrite workload on
> an existing 1MiB file, median time improved as follows:
>
> 64-byte overwrites: 1724.93 ns/write -> 1560.24 ns/write
> 256-byte overwrites: 1713.38 ns/write -> 1577.85 ns/write
>
> Function profiling of 20k 64-byte overwrites showed
> f2fs_get_inode_folio() calls drop from 20004 to 4.
>
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip inode folio lookup for cached overwrite
2026-05-29 2:29 [PATCH] f2fs: skip inode folio lookup for cached overwrite Wenjie Qi
2026-06-15 10:43 ` Chao Yu
@ 2026-06-15 15:30 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2026-06-15 15:30 UTC (permalink / raw)
To: Wenjie Qi; +Cc: jaegeuk, chao, qiwenjie, linux-kernel, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Fri, 29 May 2026 10:29:24 +0800 you wrote:
> prepare_write_begin() first gets the inode folio and builds a dnode,
> then checks the read extent cache. For an ordinary overwrite of a
> non-inline and non-compressed file, an extent-cache hit already gives the
> data block address and the following path does not need to allocate or
> update any node state.
>
> Check the read extent cache before fetching the inode folio for that
> narrow case. Keep the existing paths for inline data, compressed files,
> and writes that may extend past EOF, where the helper may need inline
> conversion, compression preparation, or block reservation.
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: skip inode folio lookup for cached overwrite
https://git.kernel.org/jaegeuk/f2fs/c/ec1a089b0c14
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] 3+ messages in thread
end of thread, other threads:[~2026-06-15 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-29 2:29 [PATCH] f2fs: skip inode folio lookup for cached overwrite Wenjie Qi
2026-06-15 10:43 ` Chao Yu
2026-06-15 15:30 ` [f2fs-dev] " patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®