Commit 58aaa083 authored by Daniel Hill's avatar Daniel Hill Committed by Kent Overstreet

bcachefs: fix __dev_available().

__dev_available() now calculates available buckets correctly. Previously
it would almost always return 0 when we have cached data.
Signed-off-by: default avatarDaniel Hill <daniel@gluo.nz>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2817d453
...@@ -159,12 +159,12 @@ static inline u64 __dev_buckets_available(struct bch_dev *ca, ...@@ -159,12 +159,12 @@ static inline u64 __dev_buckets_available(struct bch_dev *ca,
enum alloc_reserve reserve) enum alloc_reserve reserve)
{ {
return max_t(s64, 0, return max_t(s64, 0,
usage.d[BCH_DATA_free].buckets - usage.d[BCH_DATA_free].buckets
usage.d[BCH_DATA_cached].buckets - + usage.d[BCH_DATA_cached].buckets
usage.d[BCH_DATA_need_gc_gens].buckets - + usage.d[BCH_DATA_need_gc_gens].buckets
usage.d[BCH_DATA_need_discard].buckets - + usage.d[BCH_DATA_need_discard].buckets
ca->nr_open_buckets - - ca->nr_open_buckets
bch2_dev_buckets_reserved(ca, reserve)); - bch2_dev_buckets_reserved(ca, reserve));
} }
static inline u64 dev_buckets_available(struct bch_dev *ca, static inline u64 dev_buckets_available(struct bch_dev *ca,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment