mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 20:33:49 -04:00
bcachefs: Fix racy use of jiffies
Calculate the timeout, then check if it's positive before calling schedule_timeout(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user