* [PATCH] f2fs: avoid unnecessary reads in f2fs_update_meta_block()
@ 2026-10-02 6:48 Seongjae Jeong
2026-10-11 8:41 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Seongjae Jeong @ 2026-10-02 6:48 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, jsjlee1020
When the packed SSA feature is enabled, f2fs_update_meta_block()
uses f2fs_get_meta_cache_retry(), which reads the target block from
disk if the cache entry is not uptodate.
However, f2fs_update_meta_block() overwrites the entire filesystem
block with memcpy(), so the existing contents are not needed.
Partial updates to packed SSA blocks are handled separately in
write_sum_block().
Use f2fs_grab_meta_cache() unconditionally to avoid reading blocks
that will be fully overwritten. Also remove the error check, since
f2fs_grab_meta_cache() retries allocation failures internally and
does not return an error pointer.
Signed-off-by: Seongjae Jeong <jsjlee1020@gmail.com>
---
fs/f2fs/segment.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 794e0d99fc7c..51858f64e43e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2844,13 +2844,7 @@ void f2fs_update_meta_block(struct f2fs_sb_info *sbi,
{
struct f2fs_cached_block *entry;
- if (!f2fs_sb_has_packed_ssa(sbi))
- entry = f2fs_grab_meta_cache(sbi, blk_addr);
- else
- entry = f2fs_get_meta_cache_retry(sbi, blk_addr);
-
- if (IS_ERR(entry))
- return;
+ entry = f2fs_grab_meta_cache(sbi, blk_addr);
memcpy(cache_address(entry), src, F2FS_BLKSIZE(sbi));
f2fs_mark_cache_dirty(entry);
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] f2fs: avoid unnecessary reads in f2fs_update_meta_block()
2026-10-02 6:48 [PATCH] f2fs: avoid unnecessary reads in f2fs_update_meta_block() Seongjae Jeong
@ 2026-10-11 8:41 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2026-10-11 8:41 UTC (permalink / raw)
To: Daeho Jeong; +Cc: chao, linux-f2fs-devel, linux-kernel, jaegeuk, Seongjae Jeong
On 10/2/26 14:48, Seongjae Jeong wrote:
> When the packed SSA feature is enabled, f2fs_update_meta_block()
> uses f2fs_get_meta_cache_retry(), which reads the target block from
> disk if the cache entry is not uptodate.
>
> However, f2fs_update_meta_block() overwrites the entire filesystem
> block with memcpy(), so the existing contents are not needed.
> Partial updates to packed SSA blocks are handled separately in
> write_sum_block().
>
> Use f2fs_grab_meta_cache() unconditionally to avoid reading blocks
> that will be fully overwritten. Also remove the error check, since
> f2fs_grab_meta_cache() retries allocation failures internally and
> does not return an error pointer.
>
> Signed-off-by: Seongjae Jeong <jsjlee1020@gmail.com>
> ---
> fs/f2fs/segment.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 794e0d99fc7c..51858f64e43e 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2844,13 +2844,7 @@ void f2fs_update_meta_block(struct f2fs_sb_info *sbi,
> {
> struct f2fs_cached_block *entry;
>
> - if (!f2fs_sb_has_packed_ssa(sbi))
> - entry = f2fs_grab_meta_cache(sbi, blk_addr);
> - else
> - entry = f2fs_get_meta_cache_retry(sbi, blk_addr);
> -
> - if (IS_ERR(entry))
> - return;
> + entry = f2fs_grab_meta_cache(sbi, blk_addr);
Daeho,
From code side, I feel this is clean.
But, could you double check this cleanup? in case if we handle this
intentionally in original patch for something.
Thanks,
>
> memcpy(cache_address(entry), src, F2FS_BLKSIZE(sbi));
> f2fs_mark_cache_dirty(entry);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-11 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 6:48 [PATCH] f2fs: avoid unnecessary reads in f2fs_update_meta_block() Seongjae Jeong
2026-10-11 8:41 ` Chao Yu
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®