bcachefs: Ignore cached data when calculating fragmentation
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 11 Jan 2022 00:46:39 +0000 (19:46 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:22 +0000 (17:09 -0400)
commit0678cbe2cbc586c0055de2c04602bf8136bcc3fc
treef58be61fb7a365ca74b2cba9e55317275862732c
parent3763cb9566a65966cd404cf3e0c5f218e5cf5d16
bcachefs: Ignore cached data when calculating fragmentation

Previously, bucket fragmentation was considered to be bucket size -
total amount of live data, both dirty and cached.

This meant that if a bucket was full but only a small amount of data in
it was dirty - the rest cached, we'd get stuck: copygc wouldn't move the
dirty data out of the bucket and the allocator wouldn't be able to
invalidate and drop the cached data.

This changes fragmentation to exclude cached data, so that copygc will
evacuate these buckets and copygc/the allocator will always be able to
make forward progress.

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