diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-05-07 23:32:26 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2021-05-19 15:33:46 -0400 |
commit | 1c171cd163f36b550f1d240f226a82faacf2b594 (patch) | |
tree | 853fc79a4f4579aeb9d921ceb522d0d16c8fd9ed | |
parent | 6c38d55c31c7210cda78620e36a11ef999968cfc (diff) |
bcachefs: Fix usage of last_seq + encryption
jset->last_seq is in the region that's encrypted - on journal write
completion, we were using it and getting garbage. This patch shadows it
to fix.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/journal.c | 3 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/journal_types.h | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index c2773126a8c6..1400774e4c01 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -190,7 +190,8 @@ static bool __journal_entry_close(struct journal *j) * Hence, we want update/set last_seq on the current journal entry right * before we open a new one: */ - buf->data->last_seq = cpu_to_le64(journal_last_seq(j)); + buf->last_seq = journal_last_seq(j); + buf->data->last_seq = cpu_to_le64(buf->last_seq); __bch2_journal_pin_put(j, le64_to_cpu(buf->data->seq)); diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index c7fa03cfbde6..635cceb4dd21 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1237,7 +1237,7 @@ static void journal_write_done(struct closure *cl) bch2_bkey_devs(bkey_i_to_s_c(&w->key)); struct bch_replicas_padded replicas; union journal_res_state old, new; - u64 v, seq, last_seq; + u64 v, seq; int err = 0; bch2_time_stats_update(j->write_time, j->write_start_time); @@ -1256,7 +1256,6 @@ static void journal_write_done(struct closure *cl) spin_lock(&j->lock); seq = le64_to_cpu(w->data->seq); - last_seq = le64_to_cpu(w->data->last_seq); if (seq >= j->pin.front) journal_seq_pin(j, seq)->devs = devs; @@ -1267,7 +1266,7 @@ static void journal_write_done(struct closure *cl) if (!JSET_NO_FLUSH(w->data)) { j->flushed_seq_ondisk = seq; - j->last_seq_ondisk = last_seq; + j->last_seq_ondisk = w->last_seq; } /* @@ -1403,7 +1402,7 @@ void bch2_journal_write(struct closure *cl) test_bit(JOURNAL_MAY_SKIP_FLUSH, &j->flags)) { w->noflush = true; SET_JSET_NO_FLUSH(jset, true); - jset->last_seq = 0; + jset->last_seq = w->last_seq = 0; j->nr_noflush_writes++; } else { diff --git a/fs/bcachefs/journal_types.h b/fs/bcachefs/journal_types.h index a7aa12e919e2..cacab22a35c1 100644 --- a/fs/bcachefs/journal_types.h +++ b/fs/bcachefs/journal_types.h @@ -23,6 +23,7 @@ struct journal_buf { __BKEY_PADDED(key, BCH_REPLICAS_MAX); struct closure_waitlist wait; + u64 last_seq; /* copy of data->last_seq */ unsigned buf_size; /* size in bytes of @data */ unsigned sectors; /* maximum size for current entry */ |