bcachefs: Fix corruption with writeable snapshots
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 28 May 2023 03:19:13 +0000 (23:19 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:03 +0000 (17:10 -0400)
commitad520141b155786800261cc7e02ec02f0afe2643
treee4057e58691102680f0a988472c06f0cca56e4c8
parente47a390aa5946e3c5bea7a4a350a88d3bb3ba5b4
bcachefs: Fix corruption with writeable snapshots

When partially overwriting an extent in an older snapshot, the existing
extent has to be split.

If the existing extent was overwritten in a different (sibling)
snapshot, we have to ensure that the split won't be visible in the
sibling snapshot.

data_update.c already has code for this,
bch2_insert_snapshot_writeouts() - we just need to move it into
btree_update_leaf.c and change bch2_trans_update_extent() to use it as
well.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/data_update.c