mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 14:50:19 +00:00
bcachefs: Fix should_invalidate_buckets()
Like bch2_copygc_wait_amount, should_invalidate_buckets() needs to try to ensure that there are always more buckets free than the largest reserve. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
175379db20
commit
b962552eab
@ -134,11 +134,13 @@ void bch2_do_discards(struct bch_fs *);
|
||||
static inline u64 should_invalidate_buckets(struct bch_dev *ca,
|
||||
struct bch_dev_usage u)
|
||||
{
|
||||
u64 free = u.d[BCH_DATA_free].buckets +
|
||||
u.d[BCH_DATA_need_discard].buckets;
|
||||
u64 want_free = ca->mi.nbuckets >> 7;
|
||||
u64 free = max_t(s64, 0,
|
||||
u.d[BCH_DATA_free].buckets
|
||||
+ u.d[BCH_DATA_need_discard].buckets
|
||||
- bch2_dev_buckets_reserved(ca, RESERVE_none));
|
||||
|
||||
return clamp_t(s64, (ca->mi.nbuckets >> 7) - free,
|
||||
0, u.d[BCH_DATA_cached].buckets);
|
||||
return clamp_t(s64, want_free - free, 0, u.d[BCH_DATA_cached].buckets);
|
||||
}
|
||||
|
||||
void bch2_do_invalidates(struct bch_fs *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user