bcachefs: Fix a subtle race in the btree split path
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 11 Oct 2019 18:45:22 +0000 (14:45 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:29 +0000 (17:08 -0400)
commitea3532cbf7fdbb9fa4e45114532d55d1fc3ac7c2
tree304ed5223daf5a0f80a271f53f103eabfeb53406
parent9a3df993e15e0d44974d6ac7c5749c7028aa9e3c
bcachefs: Fix a subtle race in the btree split path

We have to free the old (in memory) btree node _before_ unlocking the
new nodes - else, some other thread with a read lock on the old node
could see stale data after another thread has already updated the new
node.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_update_interior.c