bcachefs: New assertion for writing to the journal after shutdown

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-02-20 21:17:15 -05:00
parent 00589cadb1
commit 497c982f05
6 changed files with 10 additions and 7 deletions

View file

@ -852,7 +852,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
if (ret)
goto err;
if (!test_bit(JOURNAL_STARTED, &c->journal.flags)) {
if (!test_bit(JOURNAL_RUNNING, &c->journal.flags)) {
ret = darray_make_room(&c->journal.early_journal_entries, jset_u64s(u64s));
if (ret)
goto err;

View file

@ -1177,12 +1177,14 @@ void bch2_fs_journal_stop(struct journal *j)
bch2_journal_meta(j);
journal_quiesce(j);
cancel_delayed_work_sync(&j->write_work);
BUG_ON(!bch2_journal_error(j) &&
test_bit(JOURNAL_REPLAY_DONE, &j->flags) &&
j->last_empty_seq != journal_cur_seq(j));
cancel_delayed_work_sync(&j->write_work);
if (!bch2_journal_error(j))
clear_bit(JOURNAL_RUNNING, &j->flags);
}
int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
@ -1256,7 +1258,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
spin_lock(&j->lock);
set_bit(JOURNAL_STARTED, &j->flags);
set_bit(JOURNAL_RUNNING, &j->flags);
j->last_flush_write = jiffies;
j->reservations.idx = j->reservations.unwritten_idx = journal_cur_seq(j);

View file

@ -372,7 +372,7 @@ static inline int bch2_journal_res_get(struct journal *j, struct journal_res *re
int ret;
EBUG_ON(res->ref);
EBUG_ON(!test_bit(JOURNAL_STARTED, &j->flags));
EBUG_ON(!test_bit(JOURNAL_RUNNING, &j->flags));
res->u64s = u64s;
@ -418,7 +418,7 @@ struct bch_dev;
static inline void bch2_journal_set_replay_done(struct journal *j)
{
BUG_ON(!test_bit(JOURNAL_STARTED, &j->flags));
BUG_ON(!test_bit(JOURNAL_RUNNING, &j->flags));
set_bit(JOURNAL_REPLAY_DONE, &j->flags);
}

View file

@ -833,7 +833,7 @@ bool bch2_journal_flush_pins(struct journal *j, u64 seq_to_flush)
/* time_stats this */
bool did_work = false;
if (!test_bit(JOURNAL_STARTED, &j->flags))
if (!test_bit(JOURNAL_RUNNING, &j->flags))
return false;
closure_wait_event(&j->async_wait,

View file

@ -131,7 +131,7 @@ enum journal_space_from {
enum journal_flags {
JOURNAL_REPLAY_DONE,
JOURNAL_STARTED,
JOURNAL_RUNNING,
JOURNAL_MAY_SKIP_FLUSH,
JOURNAL_NEED_FLUSH_WRITE,
JOURNAL_SPACE_LOW,

View file

@ -468,6 +468,7 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
* at least one non-flush write in the journal or recovery will fail:
*/
set_bit(JOURNAL_NEED_FLUSH_WRITE, &c->journal.flags);
set_bit(JOURNAL_RUNNING, &c->journal.flags);
for_each_rw_member(c, ca)
bch2_dev_allocator_add(c, ca);