mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 01:09:38 -05:00
bcachefs: Fix error reporting from bch2_journal_flush_seq
- bch2_journal_halt() was unconditionally overwriting j->err_seq, the sequence number that we failed to write - journal_write_done was updating seq_ondisk and flushed_seq_ondisk even for writes that errored, which broke the way bch2_journal_flush_seq_async() locklessly checked for completions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
f0c3f88b35
commit
9be1efe9c5
3 changed files with 15 additions and 9 deletions
|
@ -106,7 +106,12 @@ void bch2_journal_halt(struct journal *j)
|
|||
} while ((v = atomic64_cmpxchg(&j->reservations.counter,
|
||||
old.v, new.v)) != old.v);
|
||||
|
||||
j->err_seq = journal_cur_seq(j);
|
||||
/*
|
||||
* XXX: we're not using j->lock here because this can be called from
|
||||
* interrupt context, this can race with journal_write_done()
|
||||
*/
|
||||
if (!j->err_seq)
|
||||
j->err_seq = journal_cur_seq(j);
|
||||
journal_wake(j);
|
||||
closure_wake_up(&journal_cur_buf(j)->wait);
|
||||
}
|
||||
|
|
|
@ -1258,14 +1258,15 @@ static void journal_write_done(struct closure *cl)
|
|||
if (seq >= j->pin.front)
|
||||
journal_seq_pin(j, seq)->devs = w->devs_written;
|
||||
|
||||
j->seq_ondisk = seq;
|
||||
if (err && (!j->err_seq || seq < j->err_seq))
|
||||
j->err_seq = seq;
|
||||
if (!err) {
|
||||
j->seq_ondisk = seq;
|
||||
|
||||
if (!JSET_NO_FLUSH(w->data)) {
|
||||
j->flushed_seq_ondisk = seq;
|
||||
j->last_seq_ondisk = w->last_seq;
|
||||
}
|
||||
if (!JSET_NO_FLUSH(w->data)) {
|
||||
j->flushed_seq_ondisk = seq;
|
||||
j->last_seq_ondisk = w->last_seq;
|
||||
}
|
||||
} else if (!j->err_seq || seq < j->err_seq)
|
||||
j->err_seq = seq;
|
||||
|
||||
/*
|
||||
* Updating last_seq_ondisk may let bch2_journal_reclaim_work() discard
|
||||
|
|
|
@ -1480,7 +1480,7 @@ int bch2_fs_initialize(struct bch_fs *c)
|
|||
}
|
||||
|
||||
err = "error writing first journal entry";
|
||||
ret = bch2_journal_meta(&c->journal);
|
||||
ret = bch2_journal_flush(&c->journal);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue