Skip to content

Commit 848c3ff

Browse files
Chen YufanKent Overstreet
authored andcommitted
bcachefs: Convert to use jiffies macros
Use jiffies macros instead of using jiffies directly to handle wraparound. Signed-off-by: Chen Yufan <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 94932a0 commit 848c3ff

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/rcupdate.h>
3131
#include <linux/sched/task.h>
3232
#include <linux/sort.h>
33+
#include <linux/jiffies.h>
3334

3435
static void bch2_discard_one_bucket_fast(struct bch_dev *, u64);
3536

@@ -2183,7 +2184,7 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
21832184
* freespace/need_discard/need_gc_gens btrees as needed:
21842185
*/
21852186
while (1) {
2186-
if (last_updated + HZ * 10 < jiffies) {
2187+
if (time_after(jiffies, last_updated + HZ * 10)) {
21872188
bch_info(ca, "%s: currently at %llu/%llu",
21882189
__func__, iter.pos.offset, ca->mi.nbuckets);
21892190
last_updated = jiffies;

fs/bcachefs/journal_io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,8 @@ static int bch2_journal_write_pick_flush(struct journal *j, struct journal_buf *
19501950
if (error ||
19511951
w->noflush ||
19521952
(!w->must_flush &&
1953-
(jiffies - j->last_flush_write) < msecs_to_jiffies(c->opts.journal_flush_delay) &&
1953+
time_before(jiffies, j->last_flush_write +
1954+
msecs_to_jiffies(c->opts.journal_flush_delay)) &&
19541955
test_bit(JOURNAL_may_skip_flush, &j->flags))) {
19551956
w->noflush = true;
19561957
SET_JSET_NO_FLUSH(w->data, true);

fs/bcachefs/thread_with_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ int bch2_stdio_redirect_readline_timeout(struct stdio_redirect *stdio,
387387
seen = buf->buf.nr;
388388
char *n = memchr(buf->buf.data, '\n', seen);
389389

390-
if (!n && timeout != MAX_SCHEDULE_TIMEOUT && jiffies >= until) {
390+
if (!n && timeout != MAX_SCHEDULE_TIMEOUT && time_after_eq(jiffies, until)) {
391391
spin_unlock(&buf->lock);
392392
return -ETIME;
393393
}

0 commit comments

Comments
 (0)