Commit 497c982f authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: New assertion for writing to the journal after shutdown

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 00589cad
...@@ -852,7 +852,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt, ...@@ -852,7 +852,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
if (ret) if (ret)
goto err; 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)); ret = darray_make_room(&c->journal.early_journal_entries, jset_u64s(u64s));
if (ret) if (ret)
goto err; goto err;
......
...@@ -1177,12 +1177,14 @@ void bch2_fs_journal_stop(struct journal *j) ...@@ -1177,12 +1177,14 @@ void bch2_fs_journal_stop(struct journal *j)
bch2_journal_meta(j); bch2_journal_meta(j);
journal_quiesce(j); journal_quiesce(j);
cancel_delayed_work_sync(&j->write_work);
BUG_ON(!bch2_journal_error(j) && BUG_ON(!bch2_journal_error(j) &&
test_bit(JOURNAL_REPLAY_DONE, &j->flags) && test_bit(JOURNAL_REPLAY_DONE, &j->flags) &&
j->last_empty_seq != journal_cur_seq(j)); 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) 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) ...@@ -1256,7 +1258,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
spin_lock(&j->lock); spin_lock(&j->lock);
set_bit(JOURNAL_STARTED, &j->flags); set_bit(JOURNAL_RUNNING, &j->flags);
j->last_flush_write = jiffies; j->last_flush_write = jiffies;
j->reservations.idx = j->reservations.unwritten_idx = journal_cur_seq(j); j->reservations.idx = j->reservations.unwritten_idx = journal_cur_seq(j);
......
...@@ -372,7 +372,7 @@ static inline int bch2_journal_res_get(struct journal *j, struct journal_res *re ...@@ -372,7 +372,7 @@ static inline int bch2_journal_res_get(struct journal *j, struct journal_res *re
int ret; int ret;
EBUG_ON(res->ref); EBUG_ON(res->ref);
EBUG_ON(!test_bit(JOURNAL_STARTED, &j->flags)); EBUG_ON(!test_bit(JOURNAL_RUNNING, &j->flags));
res->u64s = u64s; res->u64s = u64s;
...@@ -418,7 +418,7 @@ struct bch_dev; ...@@ -418,7 +418,7 @@ struct bch_dev;
static inline void bch2_journal_set_replay_done(struct journal *j) 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); set_bit(JOURNAL_REPLAY_DONE, &j->flags);
} }
......
...@@ -833,7 +833,7 @@ bool bch2_journal_flush_pins(struct journal *j, u64 seq_to_flush) ...@@ -833,7 +833,7 @@ bool bch2_journal_flush_pins(struct journal *j, u64 seq_to_flush)
/* time_stats this */ /* time_stats this */
bool did_work = false; bool did_work = false;
if (!test_bit(JOURNAL_STARTED, &j->flags)) if (!test_bit(JOURNAL_RUNNING, &j->flags))
return false; return false;
closure_wait_event(&j->async_wait, closure_wait_event(&j->async_wait,
......
...@@ -131,7 +131,7 @@ enum journal_space_from { ...@@ -131,7 +131,7 @@ enum journal_space_from {
enum journal_flags { enum journal_flags {
JOURNAL_REPLAY_DONE, JOURNAL_REPLAY_DONE,
JOURNAL_STARTED, JOURNAL_RUNNING,
JOURNAL_MAY_SKIP_FLUSH, JOURNAL_MAY_SKIP_FLUSH,
JOURNAL_NEED_FLUSH_WRITE, JOURNAL_NEED_FLUSH_WRITE,
JOURNAL_SPACE_LOW, JOURNAL_SPACE_LOW,
......
...@@ -468,6 +468,7 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early) ...@@ -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: * 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_NEED_FLUSH_WRITE, &c->journal.flags);
set_bit(JOURNAL_RUNNING, &c->journal.flags);
for_each_rw_member(c, ca) for_each_rw_member(c, ca)
bch2_dev_allocator_add(c, ca); bch2_dev_allocator_add(c, ca);
......
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