39 lines
1.2 KiB
Diff
39 lines
1.2 KiB
Diff
From 40cfa4d5b8dcf25ae12c8fca492212e0a2b1d2cc Mon Sep 17 00:00:00 2001
|
|
From: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Date: Wed, 9 Oct 2024 16:53:59 -0400
|
|
Subject: [PATCH 002/233] bcachefs: Fix racy use of jiffies
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Calculate the timeout, then check if it's positive before calling
|
|
schedule_timeout().
|
|
|
|
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
fs/bcachefs/journal_reclaim.c | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
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;
|
|
}
|
|
--
|
|
2.45.2
|
|
|