[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c7qpzaeqhyvkbgaplvazj6steii5ayta7gtidmy24u7gfnnkuc@nhc2swhzmuff>
Date: Sun, 19 May 2024 14:25:09 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Camila Alvarez <cam.alvarez.i@...il.com>
Cc: Brian Foster <bfoster@...hat.com>, linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org, syzbot+10b936c5eaee2819b49b@...kaller.appspotmail.com
Subject: Re: [PATCH] bcachefs: fix last_seq and last_empty_seq in
bch2_fs_journal_start()
On Wed, May 15, 2024 at 11:19:20PM -0400, Camila Alvarez wrote:
> Values were left as the next possible sequence number when there were no
> entries.
>
> The fix involves updating the last_seq initial value and
> setting last_empty_seq to cur_seq - 1.
I think this is correct, but we should try to come up with some better
assertions or something to make the code clearer; we don't want off by
ones to lurk so easily.
Could you give it some thought?
>
> Reported-by: syzbot+10b936c5eaee2819b49b@...kaller.appspotmail.com
> Signed-off-by: Camila Alvarez <cam.alvarez.i@...il.com>
> ---
> fs/bcachefs/journal.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
> index adec8e1ea73e..3835c458eec9 100644
> --- a/fs/bcachefs/journal.c
> +++ b/fs/bcachefs/journal.c
> @@ -1196,7 +1196,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
> struct journal_replay *i, **_i;
> struct genradix_iter iter;
> bool had_entries = false;
> - u64 last_seq = cur_seq, nr, seq;
> + u64 last_seq = cur_seq - 1, nr, seq;
>
> genradix_for_each_reverse(&c->journal_entries, iter, _i) {
> i = *_i;
> @@ -1256,7 +1256,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
> }
>
> if (!had_entries)
> - j->last_empty_seq = cur_seq;
> + j->last_empty_seq = cur_seq - 1;
>
> spin_lock(&j->lock);
>
> --
> 2.34.1
>
Powered by blists - more mailing lists