Re: [PATCH V2] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK

From: Jan Kara

Date: Tue Feb 03 2026 - 04:08:56 EST


On Tue 03-02-26 14:30:23, Huacai Chen wrote:
> Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK
> is not enabled:
>
> INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
>
> The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK
> is not enabled, then it causes the warning message even if the writeback
> lasts for only one second.
>
> So guard the wakeup and logging with "#ifdef CONFIG_DETECT_HUNG_TASK",
> so as to eliminate the warning messages.
>
> Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.")
> Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)")
> Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>

Thanks! Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> V2: Disable wakeup and logging for !DETECT_HUNG_TASK.
>
> fs/fs-writeback.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 5444fc706ac7..bfe469fff97c 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -198,13 +198,15 @@ static void wb_queue_work(struct bdi_writeback *wb,
>
> static bool wb_wait_for_completion_cb(struct wb_completion *done)
> {
> +#ifdef CONFIG_DETECT_HUNG_TASK
> unsigned long waited_secs = (jiffies - done->wait_start) / HZ;
>
> - done->progress_stamp = jiffies;
> if (waited_secs > sysctl_hung_task_timeout_secs)
> pr_info("INFO: The task %s:%d has been waiting for writeback "
> "completion for more than %lu seconds.",
> current->comm, current->pid, waited_secs);
> +#endif
> + done->progress_stamp = jiffies;
>
> return !atomic_read(&done->cnt);
> }
> @@ -2029,11 +2031,13 @@ static long writeback_sb_inodes(struct super_block *sb,
> */
> __writeback_single_inode(inode, &wbc);
>
> +#ifdef CONFIG_DETECT_HUNG_TASK
> /* Report progress to inform the hung task detector of the progress. */
> if (work->done && work->done->progress_stamp &&
> (jiffies - work->done->progress_stamp) > HZ *
> sysctl_hung_task_timeout_secs / 2)
> wake_up_all(work->done->waitq);
> +#endif
>
> wbc_detach_inode(&wbc);
> work->nr_pages -= write_chunk - wbc.nr_to_write;
> --
> 2.47.3
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR