]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: Fix reuse of bucket before journal flush on multiple empty -> nonempty...
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 7 Dec 2024 04:15:05 +0000 (23:15 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:22 +0000 (01:36 -0500)
commit9e779f3f24fbca1594bcd70996426f3b84873bc8
tree76f6be85829a53df0cd1bec3411b34330d416604
parent89e74eccab9248d37bf329c66af0b7d4e23eac12
bcachefs: Fix reuse of bucket before journal flush on multiple empty -> nonempty transition

For each bucket we track when the bucket became nonempty and when it
became empty again: if we can ensure that there will be no journal
flushes in the range [nonempty, empty) (possibly because they occured at
the same journal sequence number), then it's safe to reuse the bucket
without waiting for a journal commit.

This is a major performance optimization for erasure coding, where
writes are initially replicated, but the extra replicas are quickly
dropped: if those buckets are reused and overwritten without issuing a
cache flush to the underlying device, then they only cost bus bandwidth.

But there's a tricky corner case when there's multiple empty -> nonempty
-> empty transitions in quick succession, i.e. when data is getting
overwritten immediately as it's being written.

If this happens and the previous empty transition hasn't been flushed,
we need to continue tracking the previous nonempty transition - not
start a new one.

Fixing this means we now need to track both the nonempty and empty
transitions in bch_alloc_v4.

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