bcachefs: Fix race between journal_seq_copy() and journal_seq_drop()
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 16 Dec 2020 20:41:29 +0000 (15:41 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:50 +0000 (17:08 -0400)
commitd483dd17e2bfd6858498d39eb92abd232d7b8e97
tree14accac982779273e6f2b769834aded96fc39de3
parentf30dd8601262c74caf148fe834418ad7c931af66
bcachefs: Fix race between journal_seq_copy() and journal_seq_drop()

In bch2_btree_interior_update_will_free_node, we copy the journal pins
from outstanding writes on the btree node we're about to free. But, this
can race with the writes completing, and dropping their journal pins.

To guard against this, just use READ_ONCE() in bch2_journal_pin_copy().

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_reclaim.c
fs/bcachefs/journal_reclaim.h