Skip to content

Commit 639924a

Browse files
Kemeng Shibrauner
authored andcommitted
fs/writeback: only calculate dirtied_before when b_io is empty
The dirtied_before is only used when b_io is not empty, so only calculate when b_io is not empty. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Link: https://lore.kernel.org/r/20240228091958.288260-5-shikemeng@huaweicloud.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 2ddc934 commit 639924a

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

fs/fs-writeback.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,20 +2105,21 @@ static long wb_writeback(struct bdi_writeback *wb,
21052105

21062106
spin_lock(&wb->list_lock);
21072107

2108-
/*
2109-
* Kupdate and background works are special and we want to
2110-
* include all inodes that need writing. Livelock avoidance is
2111-
* handled by these works yielding to any other work so we are
2112-
* safe.
2113-
*/
2114-
if (work->for_kupdate) {
2115-
dirtied_before = jiffies -
2116-
msecs_to_jiffies(dirty_expire_interval * 10);
2117-
} else if (work->for_background)
2118-
dirtied_before = jiffies;
2119-
21202108
trace_writeback_start(wb, work);
21212109
if (list_empty(&wb->b_io)) {
2110+
/*
2111+
* Kupdate and background works are special and we want
2112+
* to include all inodes that need writing. Livelock
2113+
* avoidance is handled by these works yielding to any
2114+
* other work so we are safe.
2115+
*/
2116+
if (work->for_kupdate) {
2117+
dirtied_before = jiffies -
2118+
msecs_to_jiffies(dirty_expire_interval *
2119+
10);
2120+
} else if (work->for_background)
2121+
dirtied_before = jiffies;
2122+
21222123
queue_io(wb, work, dirtied_before);
21232124
queued = true;
21242125
}

0 commit comments

Comments
 (0)