bcachefs: Don't keep tons of cached pointers around
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 21 Oct 2024 00:02:09 +0000 (20:02 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 29 Oct 2024 10:34:10 +0000 (06:34 -0400)
commita34eef6dd179463e70a97bbf8453b7ca21d1e666
treef19b88d856c29183f51b57955b6948da6a2f75f4
parent3fd27e9c57bf12c4eb1e41b87fc1aa579ec772da
bcachefs: Don't keep tons of cached pointers around

We had a bug report where the data update path was creating an extent
that failed to validate because it had too many pointers; almost all of
them were cached.

To fix this, we have:
- want_cached_ptr(), a new helper that checks if we even want a cached
  pointer (is on appropriate target, device is readable).

- bch2_extent_set_ptr_cached() now only sets a pointer cached if we want
  it.

- bch2_extent_normalize_by_opts() now ensures that we only have a single
  cached pointer that we want.

While working on this, it was noticed that this doesn't work well with
reflinked data and per-file options. Another patch series is coming that
plumbs through additional io path options through bch_extent_rebalance,
with improved option handling.

Reported-by: Reed Riley <reed@riley.engineer>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/data_update.c
fs/bcachefs/data_update.h
fs/bcachefs/extents.c
fs/bcachefs/extents.h
fs/bcachefs/move.c