From: Kent Overstreet Date: Wed, 9 Oct 2024 20:53:59 +0000 (-0400) Subject: bcachefs: Fix racy use of jiffies X-Git-Tag: v6.14-rc1~204^2~266 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=135c0c85248a10512a9c5d17dccf65e220398cf4;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Fix racy use of jiffies Calculate the timeout, then check if it's positive before calling schedule_timeout(). Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index ace291f175dd..3d8fc2642425 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -758,10 +758,12 @@ static int bch2_journal_reclaim_thread(void *arg) journal_empty = fifo_empty(&j->pin); spin_unlock(&j->lock); + long timeout = j->next_reclaim - jiffies; + if (journal_empty) schedule(); - else if (time_after(j->next_reclaim, jiffies)) - schedule_timeout(j->next_reclaim - jiffies); + else if (timeout > 0) + schedule_timeout(timeout); else break; }