Skip to content

Commit 9eed043

Browse files
chenhuacaibrauner
authored andcommitted
writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
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. Guard the wakeup and logging with "#ifdef CONFIG_DETECT_HUNG_TASK" can eliminate the warning messages. But on the other hand, it is possible that sysctl_hung_task_timeout_secs be also 0 when DETECT_HUNG_TASK is enabled. So let's just check the value of sysctl_hung_task_timeout_secs to decide whether do wakeup and logging. Fixes: 1888635 ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.") Fixes: d6e6215 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)") Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Link: https://patch.msgid.link/20260203094014.2273240-1-chenhuacai@loongson.cn Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent cb184dd commit 9eed043

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

fs/fs-writeback.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ static void wb_queue_work(struct bdi_writeback *wb,
198198

199199
static bool wb_wait_for_completion_cb(struct wb_completion *done)
200200
{
201+
unsigned long timeout = sysctl_hung_task_timeout_secs;
201202
unsigned long waited_secs = (jiffies - done->wait_start) / HZ;
202203

203204
done->progress_stamp = jiffies;
204-
if (waited_secs > sysctl_hung_task_timeout_secs)
205+
if (timeout && (waited_secs > timeout))
205206
pr_info("INFO: The task %s:%d has been waiting for writeback "
206207
"completion for more than %lu seconds.",
207208
current->comm, current->pid, waited_secs);
@@ -1955,6 +1956,7 @@ static long writeback_sb_inodes(struct super_block *sb,
19551956
.range_end = LLONG_MAX,
19561957
};
19571958
unsigned long start_time = jiffies;
1959+
unsigned long timeout = sysctl_hung_task_timeout_secs;
19581960
long write_chunk;
19591961
long total_wrote = 0; /* count both pages and inodes */
19601962
unsigned long dirtied_before = jiffies;
@@ -2041,9 +2043,8 @@ static long writeback_sb_inodes(struct super_block *sb,
20412043
__writeback_single_inode(inode, &wbc);
20422044

20432045
/* Report progress to inform the hung task detector of the progress. */
2044-
if (work->done && work->done->progress_stamp &&
2045-
(jiffies - work->done->progress_stamp) > HZ *
2046-
sysctl_hung_task_timeout_secs / 2)
2046+
if (work->done && work->done->progress_stamp && timeout &&
2047+
(jiffies - work->done->progress_stamp) > HZ * timeout / 2)
20472048
wake_up_all(work->done->waitq);
20482049

20492050
wbc_detach_inode(&wbc);

0 commit comments

Comments
 (0)