bcachefs: Fix race between btree updates & journal replay
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 31 Dec 2021 22:54:13 +0000 (17:54 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:21 +0000 (17:09 -0400)
commitdfd41fb9f24699393a042f9c34bd46496da1174d
treec92bb60a1514fcec6067b65ed9ac0450c3ac4c96
parent528b18e6d1c67ccf4ab01cdee94299f3ac61e1ec
bcachefs: Fix race between btree updates & journal replay

Add a flag to indicate whether a journal replay key has been
overwritten, and set/test it with appropriate btree locks held.

This fixes a race between the allocator - invalidating buckets, and
doing btree updates - and journal replay, which before this patch could
clobber the allocator thread's update with an older version of the key
from the journal.

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