bcachefs: move journal seq assertion
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 27 Nov 2023 05:53:46 +0000 (00:53 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 29 Nov 2023 03:58:22 +0000 (22:58 -0500)
journal_cur_seq() can legitimately be used outside of the journal lock,
where this assert can race

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal.h

index 23a9b7845d11975313414ef8a24bad4345a0d605..489b34046e7807744bdc7b8462910e5d9d4dc53a 100644 (file)
@@ -321,6 +321,8 @@ static int journal_entry_open(struct journal *j)
        atomic64_inc(&j->seq);
        journal_pin_list_init(fifo_push_ref(&j->pin), 1);
 
+       BUG_ON(j->pin.back - 1 != atomic64_read(&j->seq));
+
        BUG_ON(j->buf + (journal_cur_seq(j) & JOURNAL_BUF_MASK) != buf);
 
        bkey_extent_init(&buf->key);
index c85d01cf49484984d08d20a2159f84b2506f96a1..4c513fca5ef2d1db0c1bc9673359235912505afc 100644 (file)
@@ -136,9 +136,7 @@ static inline u64 journal_last_seq(struct journal *j)
 
 static inline u64 journal_cur_seq(struct journal *j)
 {
-       EBUG_ON(j->pin.back - 1 != atomic64_read(&j->seq));
-
-       return j->pin.back - 1;
+       return atomic64_read(&j->seq);
 }
 
 static inline u64 journal_last_unwritten_seq(struct journal *j)