diff options
Diffstat (limited to 'libbcachefs/buckets.h')
-rw-r--r-- | libbcachefs/buckets.h | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/libbcachefs/buckets.h b/libbcachefs/buckets.h index 3b82d7f3..f99a62bc 100644 --- a/libbcachefs/buckets.h +++ b/libbcachefs/buckets.h @@ -95,33 +95,6 @@ static inline u8 ptr_stale(const struct bch_dev *ca, return gen_after(PTR_BUCKET(ca, ptr)->mark.gen, ptr->gen); } -/* bucket heaps */ - -static inline bool bucket_min_cmp(struct bucket_heap_entry l, - struct bucket_heap_entry r) -{ - return l.val < r.val; -} - -static inline bool bucket_max_cmp(struct bucket_heap_entry l, - struct bucket_heap_entry r) -{ - return l.val > r.val; -} - -static inline void bucket_heap_push(struct bch_dev *ca, struct bucket *g, - unsigned long val) -{ - struct bucket_heap_entry new = { g, val }; - - if (!heap_full(&ca->heap)) - heap_add(&ca->heap, new, bucket_min_cmp); - else if (bucket_min_cmp(new, heap_peek(&ca->heap))) { - ca->heap.data[0] = new; - heap_sift(&ca->heap, 0, bucket_min_cmp); - } -} - /* bucket gc marks */ /* The dirty and cached sector counts saturate. If this occurs, @@ -129,14 +102,16 @@ static inline void bucket_heap_push(struct bch_dev *ca, struct bucket *g, * GC must be performed. */ #define GC_MAX_SECTORS_USED ((1U << 15) - 1) -static inline bool bucket_unused(struct bucket *g) +static inline unsigned bucket_sectors_used(struct bucket_mark mark) { - return !g->mark.counter; + return mark.dirty_sectors + mark.cached_sectors; } -static inline unsigned bucket_sectors_used(struct bucket *g) +static inline bool bucket_unused(struct bucket_mark mark) { - return g->mark.dirty_sectors + g->mark.cached_sectors; + return !mark.owned_by_allocator && + !mark.data_type && + !bucket_sectors_used(mark); } /* Per device stats: */ |