Commit 8511632d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Journal initialization fixes

This fixes a rare bug when mounting & unmounting RO - flushing a clean
filesystem that never went RO should be a no op.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent ffa7d262
...@@ -989,10 +989,14 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq, ...@@ -989,10 +989,14 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq,
j->replay_journal_seq = last_seq; j->replay_journal_seq = last_seq;
j->replay_journal_seq_end = cur_seq; j->replay_journal_seq_end = cur_seq;
j->last_seq_ondisk = last_seq; j->last_seq_ondisk = last_seq;
j->flushed_seq_ondisk = cur_seq - 1;
j->pin.front = last_seq; j->pin.front = last_seq;
j->pin.back = cur_seq; j->pin.back = cur_seq;
atomic64_set(&j->seq, cur_seq - 1); atomic64_set(&j->seq, cur_seq - 1);
if (list_empty(journal_entries))
j->last_empty_seq = cur_seq - 1;
fifo_for_each_entry_ptr(p, &j->pin, seq) fifo_for_each_entry_ptr(p, &j->pin, seq)
journal_pin_list_init(p, 1); journal_pin_list_init(p, 1);
...@@ -1005,6 +1009,9 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq, ...@@ -1005,6 +1009,9 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq,
if (seq < last_seq) if (seq < last_seq)
continue; continue;
if (journal_entry_empty(&i->j))
j->last_empty_seq = le64_to_cpu(i->j.seq);
p = journal_seq_pin(j, seq); p = journal_seq_pin(j, seq);
p->devs.nr = 0; p->devs.nr = 0;
...@@ -1012,6 +1019,9 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq, ...@@ -1012,6 +1019,9 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq,
bch2_dev_list_add_dev(&p->devs, i->ptrs[ptr].dev); bch2_dev_list_add_dev(&p->devs, i->ptrs[ptr].dev);
} }
if (list_empty(journal_entries))
j->last_empty_seq = cur_seq;
spin_lock(&j->lock); spin_lock(&j->lock);
set_bit(JOURNAL_STARTED, &j->flags); set_bit(JOURNAL_STARTED, &j->flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment