Commit 2d155128 authored by Kemeng Shi's avatar Kemeng Shi Committed by Zhihao Cheng
Browse files

fs/writeback: only calculate dirtied_before when b_io is empty

mainline inclusion
from mainline-next-20240508
commit 639924abc1ae28eb05893a402081e8e6cff23b8a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9NOHO

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/fs?id=639924abc1ae28eb05893a402081e8e6cff23b8a



--------------------------------

The dirtied_before is only used when b_io is not empty, so only calculate
when b_io is not empty.

Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
Link: https://lore.kernel.org/r/20240228091958.288260-5-shikemeng@huaweicloud.com


Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarZhihao Cheng <chengzhihao@huaweicloud.com>
parent 75078f68
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -2080,20 +2080,21 @@ static long wb_writeback(struct bdi_writeback *wb,

		spin_lock(&wb->list_lock);

		trace_writeback_start(wb, work);
		if (list_empty(&wb->b_io)) {
			/*
		 * Kupdate and background works are special and we want to
		 * include all inodes that need writing. Livelock avoidance is
		 * handled by these works yielding to any other work so we are
		 * safe.
			 * Kupdate and background works are special and we want
			 * to include all inodes that need writing. Livelock
			 * avoidance is handled by these works yielding to any
			 * other work so we are safe.
			 */
			if (work->for_kupdate) {
				dirtied_before = jiffies -
				msecs_to_jiffies(dirty_expire_interval * 10);
					msecs_to_jiffies(dirty_expire_interval *
							 10);
			} else if (work->for_background)
				dirtied_before = jiffies;

		trace_writeback_start(wb, work);
		if (list_empty(&wb->b_io)) {
			queue_io(wb, work, dirtied_before);
			queued = true;
		}