summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-27 23:16:25 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:04 -0400
commitd797ca3d8ed3b493d6558426fb4b4980ff186c37 (patch)
tree13d3b6099cd86e774510cd7061d791660e0e0800 /fs/bcachefs/journal_io.c
parent9eba7c8d15ce236b8033ae1f50fc1168984a507b (diff)
downloadlwn-d797ca3d8ed3b493d6558426fb4b4980ff186c37.tar.gz
lwn-d797ca3d8ed3b493d6558426fb4b4980ff186c37.zip
bcachefs: Fix journal write error path
Journal write errors were racing with the submission path - potentially causing writes to other replicas to not get submitted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r--fs/bcachefs/journal_io.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 66a0e44a21a6..e42ca2a5e201 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1232,8 +1232,6 @@ static void journal_write_done(struct closure *cl)
struct journal *j = container_of(cl, struct journal, io);
struct bch_fs *c = container_of(j, struct bch_fs, journal);
struct journal_buf *w = journal_last_unwritten_buf(j);
- struct bch_devs_list devs =
- bch2_bkey_devs(bkey_i_to_s_c(&w->key));
struct bch_replicas_padded replicas;
union journal_res_state old, new;
u64 v, seq;
@@ -1241,11 +1239,12 @@ static void journal_write_done(struct closure *cl)
bch2_time_stats_update(j->write_time, j->write_start_time);
- if (!devs.nr) {
+ if (!w->devs_written.nr) {
bch_err(c, "unable to write journal to sufficient devices");
err = -EIO;
} else {
- bch2_devlist_to_replicas(&replicas.e, BCH_DATA_journal, devs);
+ bch2_devlist_to_replicas(&replicas.e, BCH_DATA_journal,
+ w->devs_written);
if (bch2_mark_replicas(c, &replicas.e))
err = -EIO;
}
@@ -1257,7 +1256,7 @@ static void journal_write_done(struct closure *cl)
seq = le64_to_cpu(w->data->seq);
if (seq >= j->pin.front)
- journal_seq_pin(j, seq)->devs = devs;
+ journal_seq_pin(j, seq)->devs = w->devs_written;
j->seq_ondisk = seq;
if (err && (!j->err_seq || seq < j->err_seq))
@@ -1307,15 +1306,15 @@ static void journal_write_endio(struct bio *bio)
{
struct bch_dev *ca = bio->bi_private;
struct journal *j = &ca->fs->journal;
+ struct journal_buf *w = journal_last_unwritten_buf(j);
+ unsigned long flags;
- if (bch2_dev_io_err_on(bio->bi_status, ca, "journal write error: %s",
+ if (bch2_dev_io_err_on(bio->bi_status, ca, "error writing journal entry %llu: %s",
+ le64_to_cpu(w->data->seq),
bch2_blk_status_to_str(bio->bi_status)) ||
bch2_meta_write_fault("journal")) {
- struct journal_buf *w = journal_last_unwritten_buf(j);
- unsigned long flags;
-
spin_lock_irqsave(&j->err_lock, flags);
- bch2_bkey_drop_device(bkey_i_to_s(&w->key), ca->dev_idx);
+ bch2_dev_list_drop_dev(&w->devs_written, ca->dev_idx);
spin_unlock_irqrestore(&j->err_lock, flags);
}
@@ -1510,10 +1509,8 @@ retry_alloc:
return;
}
- /*
- * XXX: we really should just disable the entire journal in nochanges
- * mode
- */
+ w->devs_written = bch2_bkey_devs(bkey_i_to_s_c(&w->key));
+
if (c->opts.nochanges)
goto no_io;