]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: dump more information when checkpoint was blocked for long time
authorChao Yu <chao@kernel.org>
Thu, 31 Jul 2025 05:34:04 +0000 (13:34 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 11 Aug 2025 17:03:27 +0000 (17:03 +0000)
generic/299 w/ mode=lfs will cause long time latency of checkpoint,
let's dump more information once we hit case.

CP merge:
  - Queued :    0
  - Issued :    1
  - Total :    1
  - Cur time : 9765(ms)
  - Peak time : 9765(ms)

F2FS-fs (vdc): blocked on checkpoint for 9765 ms
CPU: 11 UID: 0 PID: 237 Comm: kworker/u128:29 Tainted: G           O        6.16.0-rc3+ #409 PREEMPT(voluntary)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: writeback wb_workfn (flush-253:32)
Call Trace:
 <TASK>
 dump_stack_lvl+0x6e/0xa0
 f2fs_issue_checkpoint+0x268/0x280
 f2fs_write_node_pages+0x6a/0x2c0
 do_writepages+0xd0/0x170
 __writeback_single_inode+0x56/0x4c0
 writeback_sb_inodes+0x22a/0x550
 __writeback_inodes_wb+0x4c/0xf0
 wb_writeback+0x300/0x400
 wb_workfn+0x3de/0x500
 process_one_work+0x230/0x5c0
 worker_thread+0x1da/0x3d0
 kthread+0x10d/0x250
 ret_from_fork+0x164/0x190
 ret_from_fork_asm+0x1a/0x30

Cc: Jan Prusakowski <jprusakowski@google.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h

index db3831f7f2f5aae6b607c3d39f515f4d69930a5e..02806e2edce4ba60b877a4d8f0f25a19ba67e87e 100644 (file)
@@ -1778,6 +1778,7 @@ static void __checkpoint_and_complete_reqs(struct f2fs_sb_info *sbi)
        llist_for_each_entry_safe(req, next, dispatch_list, llnode) {
                diff = (u64)ktime_ms_delta(ktime_get(), req->queue_time);
                req->ret = ret;
+               req->delta_time = diff;
                complete(&req->wait);
 
                sum_diff += diff;
@@ -1873,6 +1874,12 @@ int f2fs_issue_checkpoint(struct f2fs_sb_info *sbi)
        else
                flush_remained_ckpt_reqs(sbi, &req);
 
+       if (unlikely(req.delta_time >= CP_LONG_LATENCY_THRESHOLD)) {
+               f2fs_warn_ratelimited(sbi,
+                       "blocked on checkpoint for %u ms", cprc->peak_time);
+               dump_stack();
+       }
+
        return req.ret;
 }
 
index 46be7560548ce22fe89d60918fc1528f16f39011..7b567ab953e47453c50fd3803152eb9c5246f1f2 100644 (file)
@@ -334,7 +334,10 @@ struct ckpt_req {
        struct completion wait;         /* completion for checkpoint done */
        struct llist_node llnode;       /* llist_node to be linked in wait queue */
        int ret;                        /* return code of checkpoint */
-       ktime_t queue_time;             /* request queued time */
+       union {
+               ktime_t queue_time;     /* request queued time */
+               ktime_t delta_time;     /* time in queue */
+       };
 };
 
 struct ckpt_req_control {
@@ -350,6 +353,9 @@ struct ckpt_req_control {
        unsigned int peak_time;         /* peak wait time in msec until now */
 };
 
+/* a time threshold that checkpoint was blocked for, unit: ms */
+#define CP_LONG_LATENCY_THRESHOLD      5000
+
 /* for the bitmap indicate blocks to be discarded */
 struct discard_entry {
        struct list_head list;  /* list head */