[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <vthxausjk2h5dujrtef7odyxpl35l5bgak7ce5sbtietsh43ib@3njnr6xcfdtt>
Date: Wed, 21 Aug 2024 23:01:15 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Chen Yufan <chenyufan@...o.com>
Cc: linux-bcachefs@...r.kernel.org, linux-kernel@...r.kernel.org,
opensource.kernel@...o.com
Subject: Re: [PATCH v1] bcachefs: Convert to use jiffies macros
On Thu, Aug 22, 2024 at 10:57:31AM GMT, Chen Yufan wrote:
> Use jiffies macros instead of using jiffies directly to handle wraparound.
>
> Signed-off-by: Chen Yufan <chenyufan@...o.com>
Applied
> ---
> fs/bcachefs/alloc_background.c | 3 ++-
> fs/bcachefs/journal_io.c | 3 ++-
> fs/bcachefs/thread_with_file.c | 2 +-
> 3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
> index ac933142a..795539556 100644
> --- a/fs/bcachefs/alloc_background.c
> +++ b/fs/bcachefs/alloc_background.c
> @@ -30,6 +30,7 @@
> #include <linux/rcupdate.h>
> #include <linux/sched/task.h>
> #include <linux/sort.h>
> +#include <linux/jiffies.h>
>
> static void bch2_discard_one_bucket_fast(struct bch_dev *, u64);
>
> @@ -2181,7 +2182,7 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
> * freespace/need_discard/need_gc_gens btrees as needed:
> */
> while (1) {
> - if (last_updated + HZ * 10 < jiffies) {
> + if (time_after(jiffies, last_updated + HZ * 10)) {
> bch_info(ca, "%s: currently at %llu/%llu",
> __func__, iter.pos.offset, ca->mi.nbuckets);
> last_updated = jiffies;
> diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
> index 7664b68e6..32b886feb 100644
> --- a/fs/bcachefs/journal_io.c
> +++ b/fs/bcachefs/journal_io.c
> @@ -1950,7 +1950,8 @@ static int bch2_journal_write_pick_flush(struct journal *j, struct journal_buf *
> if (error ||
> w->noflush ||
> (!w->must_flush &&
> - (jiffies - j->last_flush_write) < msecs_to_jiffies(c->opts.journal_flush_delay) &&
> + time_before(jiffies, j->last_flush_write +
> + msecs_to_jiffies(c->opts.journal_flush_delay)) &&
> test_bit(JOURNAL_may_skip_flush, &j->flags))) {
> w->noflush = true;
> SET_JSET_NO_FLUSH(w->data, true);
> diff --git a/fs/bcachefs/thread_with_file.c b/fs/bcachefs/thread_with_file.c
> index 0807ce9b1..fb3442a7c 100644
> --- a/fs/bcachefs/thread_with_file.c
> +++ b/fs/bcachefs/thread_with_file.c
> @@ -387,7 +387,7 @@ int bch2_stdio_redirect_readline_timeout(struct stdio_redirect *stdio,
> seen = buf->buf.nr;
> char *n = memchr(buf->buf.data, '\n', seen);
>
> - if (!n && timeout != MAX_SCHEDULE_TIMEOUT && jiffies >= until) {
> + if (!n && timeout != MAX_SCHEDULE_TIMEOUT && time_after_eq(jiffies, until)) {
> spin_unlock(&buf->lock);
> return -ETIME;
> }
> --
> 2.39.0
>
Powered by blists - more mailing lists