* [f2fs-dev] [PATCH v2 1/3] f2fs: add write latency stats for NAT and SIT blocks in f2fs_write_checkpoint
2026-01-13 15:21 [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads Yongpeng Yang
@ 2026-01-13 15:21 ` Yongpeng Yang
2026-01-20 12:27 ` Chao Yu via Linux-f2fs-devel
2026-01-13 15:21 ` [f2fs-dev] [PATCH v2 2/3] f2fs: change size parameter of __has_cursum_space() to unsigned int Yongpeng Yang
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Yongpeng Yang @ 2026-01-13 15:21 UTC (permalink / raw)
To: Chao Yu, Jaegeuk Kim; +Cc: Yongpeng Yang, Yongpeng Yang, linux-f2fs-devel
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
This patch adds separate write latency accounting for NAT and SIT blocks
in f2fs_write_checkpoint().
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/f2fs/checkpoint.c | 4 +++-
fs/f2fs/f2fs.h | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 3dfc83a0813e..7a67e23d0e33 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1840,6 +1840,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
goto out;
}
}
+ stat_cp_time(cpc, CP_TIME_MERGE_WRITE);
/*
* update checkpoint pack index
@@ -1856,10 +1857,11 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
f2fs_bug_on(sbi, !f2fs_cp_error(sbi));
goto stop;
}
+ stat_cp_time(cpc, CP_TIME_FLUSH_NAT);
f2fs_flush_sit_entries(sbi, cpc);
- stat_cp_time(cpc, CP_TIME_FLUSH_META);
+ stat_cp_time(cpc, CP_TIME_FLUSH_SIT);
/* save inmem log status */
f2fs_save_inmem_curseg(sbi);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index ded41b416ed7..bc666cfa83d4 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -319,7 +319,9 @@ enum cp_time {
CP_TIME_START, /* begin */
CP_TIME_LOCK, /* after cp_global_sem */
CP_TIME_OP_LOCK, /* after block_operation */
- CP_TIME_FLUSH_META, /* after flush sit/nat */
+ CP_TIME_MERGE_WRITE, /* after flush DATA/NODE/META */
+ CP_TIME_FLUSH_NAT, /* after flush nat */
+ CP_TIME_FLUSH_SIT, /* after flush sit */
CP_TIME_SYNC_META, /* after sync_meta_pages */
CP_TIME_SYNC_CP_META, /* after sync cp meta pages */
CP_TIME_WAIT_DIRTY_META,/* after wait on dirty meta */
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread* [f2fs-dev] [PATCH v2 2/3] f2fs: change size parameter of __has_cursum_space() to unsigned int
2026-01-13 15:21 [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads Yongpeng Yang
2026-01-13 15:21 ` [f2fs-dev] [PATCH v2 1/3] f2fs: add write latency stats for NAT and SIT blocks in f2fs_write_checkpoint Yongpeng Yang
@ 2026-01-13 15:21 ` Yongpeng Yang
2026-01-20 12:27 ` Chao Yu via Linux-f2fs-devel
2026-01-13 15:23 ` [f2fs-dev] [PATCH v2 3/3] f2fs: optimize NAT block loading during checkpoint write Yongpeng Yang
2026-01-22 23:50 ` [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads patchwork-bot+f2fs--- via Linux-f2fs-devel
3 siblings, 1 reply; 8+ messages in thread
From: Yongpeng Yang @ 2026-01-13 15:21 UTC (permalink / raw)
To: Chao Yu, Jaegeuk Kim; +Cc: Yongpeng Yang, Yongpeng Yang, linux-f2fs-devel
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
All callers of __has_cursum_space() pass an unsigned int value as the
size parameter. Change the parameter type to unsigned int accordingly.
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/f2fs/f2fs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index bc666cfa83d4..1f4698a7b72f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -572,7 +572,7 @@ static inline int update_sits_in_cursum(struct f2fs_journal *journal, int i)
}
static inline bool __has_cursum_space(struct f2fs_journal *journal,
- int size, int type)
+ unsigned int size, int type)
{
if (type == NAT_JOURNAL)
return size <= MAX_NAT_JENTRIES(journal);
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread* [f2fs-dev] [PATCH v2 3/3] f2fs: optimize NAT block loading during checkpoint write
2026-01-13 15:21 [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads Yongpeng Yang
2026-01-13 15:21 ` [f2fs-dev] [PATCH v2 1/3] f2fs: add write latency stats for NAT and SIT blocks in f2fs_write_checkpoint Yongpeng Yang
2026-01-13 15:21 ` [f2fs-dev] [PATCH v2 2/3] f2fs: change size parameter of __has_cursum_space() to unsigned int Yongpeng Yang
@ 2026-01-13 15:23 ` Yongpeng Yang
2026-01-20 12:32 ` Chao Yu via Linux-f2fs-devel
2026-01-22 23:50 ` [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads patchwork-bot+f2fs--- via Linux-f2fs-devel
3 siblings, 1 reply; 8+ messages in thread
From: Yongpeng Yang @ 2026-01-13 15:23 UTC (permalink / raw)
To: Chao Yu, Jaegeuk Kim; +Cc: Yongpeng Yang, Yongpeng Yang, linux-f2fs-devel
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
Under stress tests with frequent metadata operations, checkpoint write
time can become excessively long. Analysis shows that the slowdown is
caused by synchronous, one-by-one reads of NAT blocks during checkpoint
processing.
The issue can be reproduced with the following workload:
1. seq 1 650000 | xargs -P 16 -n 1 touch
2. sync # avoid checkpoint write during deleting
3. delete 1 file every 455 files
4. echo 3 > /proc/sys/vm/drop_caches
5. sync # trigger checkpoint write
This patch submits read I/O for all NAT blocks required in the
__flush_nat_entry_set() phase in advance, reducing the overhead of
synchronous waiting for individual NAT block reads.
The NAT block flush latency before and after the change is as below:
| |NAT blocks accessed|NAT blocks read|Flush time (ms)|
|-------------|-------------------|---------------|---------------|
|Before change|1205 |1191 |158 |
|After change |1264 |1242 |11 |
With a similar number of NAT blocks accessed and read from disk, adding
NAT block readahead reduces the total NAT block flush time by more than
90%.
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/f2fs/node.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 99e425e8c00a..fa1ddfd6633f 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -3164,7 +3164,7 @@ int f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
struct f2fs_journal *journal = curseg->journal;
struct nat_entry_set *setvec[NAT_VEC_SIZE];
struct nat_entry_set *set, *tmp;
- unsigned int found;
+ unsigned int found, entry_count = 0;
nid_t set_idx = 0;
LIST_HEAD(sets);
int err = 0;
@@ -3204,6 +3204,17 @@ int f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
MAX_NAT_JENTRIES(journal));
}
+ /*
+ * Readahead the current NAT block to prevent read requests from
+ * being issued and waited on one by one.
+ */
+ list_for_each_entry(set, &sets, set_list) {
+ entry_count += set->entry_cnt;
+ if (!enabled_nat_bits(sbi, cpc) &&
+ __has_cursum_space(journal, entry_count, NAT_JOURNAL))
+ continue;
+ f2fs_ra_meta_pages(sbi, set->set, 1, META_NAT, true);
+ }
/* flush dirty nats in nat entry set */
list_for_each_entry_safe(set, tmp, &sets, set_list) {
err = __flush_nat_entry_set(sbi, set, cpc);
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [f2fs-dev] [PATCH v2 3/3] f2fs: optimize NAT block loading during checkpoint write
2026-01-13 15:23 ` [f2fs-dev] [PATCH v2 3/3] f2fs: optimize NAT block loading during checkpoint write Yongpeng Yang
@ 2026-01-20 12:32 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-01-20 12:32 UTC (permalink / raw)
To: Yongpeng Yang, Jaegeuk Kim; +Cc: Yongpeng Yang, linux-f2fs-devel
On 1/13/2026 11:23 PM, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> Under stress tests with frequent metadata operations, checkpoint write
> time can become excessively long. Analysis shows that the slowdown is
> caused by synchronous, one-by-one reads of NAT blocks during checkpoint
> processing.
>
> The issue can be reproduced with the following workload:
> 1. seq 1 650000 | xargs -P 16 -n 1 touch
> 2. sync # avoid checkpoint write during deleting
> 3. delete 1 file every 455 files
> 4. echo 3 > /proc/sys/vm/drop_caches
> 5. sync # trigger checkpoint write
>
> This patch submits read I/O for all NAT blocks required in the
> __flush_nat_entry_set() phase in advance, reducing the overhead of
> synchronous waiting for individual NAT block reads.
>
> The NAT block flush latency before and after the change is as below:
>
> | |NAT blocks accessed|NAT blocks read|Flush time (ms)|
> |-------------|-------------------|---------------|---------------|
> |Before change|1205 |1191 |158 |
> |After change |1264 |1242 |11 |
>
> With a similar number of NAT blocks accessed and read from disk, adding
> NAT block readahead reduces the total NAT block flush time by more than
> 90%.
>
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.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] 8+ messages in thread
* Re: [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads
2026-01-13 15:21 [f2fs-dev] [PATCH v2 0/3] f2fs: reduce checkpoint write latency under metadata-intensive workloads Yongpeng Yang
` (2 preceding siblings ...)
2026-01-13 15:23 ` [f2fs-dev] [PATCH v2 3/3] f2fs: optimize NAT block loading during checkpoint write Yongpeng Yang
@ 2026-01-22 23:50 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2026-01-22 23:50 UTC (permalink / raw)
To: Yongpeng Yang; +Cc: jaegeuk, yangyongpeng, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Tue, 13 Jan 2026 23:21:36 +0800 you wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> This patch series addresses long checkpoint write latency observed under
> workloads with frequent metadata operations. Analysis shows that the main
> bottleneck is high synchronous read latency of NAT blocks during checkpoint
> processing.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2,1/3] f2fs: add write latency stats for NAT and SIT blocks in f2fs_write_checkpoint
https://git.kernel.org/jaegeuk/f2fs/c/10f96e94b38d
- [f2fs-dev,v2,2/3] f2fs: change size parameter of __has_cursum_space() to unsigned int
(no matching commit)
- [f2fs-dev,v2,3/3] f2fs: optimize NAT block loading during checkpoint write
(no matching commit)
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] 8+ messages in thread