bcachefs: Handle race between stripe reuse, invalidate_stripe_to_dev
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 13 Oct 2024 23:38:00 +0000 (19:38 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 14 Oct 2024 02:03:03 +0000 (22:03 -0400)
commitcb6055e66faa0d4c15587ef67be18bc199aef085
treec2da553f08c46b5b46791514001bd2187969fe9b
parentb1e562265ed801c36e8817c67c97a47137870ece
bcachefs: Handle race between stripe reuse, invalidate_stripe_to_dev

When creating a new stripe, we may reuse an existing stripe that has
some empty and some nonempty blocks.

Generally, the existing stripe won't change underneath us - except for
block sector counts, which we copy to the new key in
ec_stripe_key_update.

But the device removal path can now invalidate stripe pointers to a
device, and that can race with stripe reuse.

Change ec_stripe_key_update() to check for and resolve this
inconsistency.

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