diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-17 17:54:39 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-13 21:22:25 -0400 |
commit | d9290c9931e4c2ff27b13209610521681418e194 (patch) | |
tree | 52a864d8fb1883192f6d922532c7489b3fd714f2 /fs/bcachefs/journal_io.c | |
parent | a393f3312387597d2e3b6b44bf50ef7f105f623d (diff) | |
download | linux-stable-d9290c9931e4c2ff27b13209610521681418e194.tar.gz linux-stable-d9290c9931e4c2ff27b13209610521681418e194.tar.bz2 linux-stable-d9290c9931e4c2ff27b13209610521681418e194.zip |
bcachefs: Fix journal_buf bitfield accesses
All jounal_buf bitfield updates must happen under the journal lock -
perhaps we should just switch these to atomic bit flags.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index c4f19b996b45..3aff628e05ca 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1831,7 +1831,10 @@ static int bch2_journal_write_prep(struct journal *j, struct journal_buf *w) if (wb.wb) bch2_journal_keys_to_write_buffer_end(c, &wb); + + spin_lock(&c->journal.lock); w->need_flush_to_write_buffer = false; + spin_unlock(&c->journal.lock); start = end = vstruct_last(jset); @@ -1949,12 +1952,20 @@ CLOSURE_CALLBACK(bch2_journal_write) unsigned nr_rw_members = 0; int ret; + for_each_rw_member(c, ca) + nr_rw_members++; + BUG_ON(BCH_SB_CLEAN(c->disk_sb.sb)); + BUG_ON(!w->write_started); BUG_ON(w->write_allocated); + BUG_ON(w->write_done); j->write_start_time = local_clock(); spin_lock(&j->lock); + if (nr_rw_members > 1) + w->separate_flush = true; + ret = bch2_journal_write_pick_flush(j, w); spin_unlock(&j->lock); if (ret) @@ -2009,12 +2020,6 @@ CLOSURE_CALLBACK(bch2_journal_write) if (c->opts.nochanges) goto no_io; - for_each_rw_member(c, ca) - nr_rw_members++; - - if (nr_rw_members > 1) - w->separate_flush = true; - /* * Mark journal replicas before we submit the write to guarantee * recovery will find the journal entries after a crash. |