1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_ALLOC_TYPES_H
3 #define _BCACHEFS_ALLOC_TYPES_H
5 #include <linux/mutex.h>
6 #include <linux/spinlock.h>
8 #include "clock_types.h"
13 #define ALLOC_THREAD_STATES() \
19 enum allocator_states {
20 #define x(n) ALLOCATOR_##n,
26 RESERVE_BTREE_MOVINGGC = -2,
33 typedef FIFO(long) alloc_fifo;
35 #define OPEN_BUCKETS_COUNT 1024
37 #define WRITE_POINT_HASH_NR 32
38 #define WRITE_POINT_MAX 32
41 * 0 is never a valid open_bucket_idx_t:
43 typedef u16 open_bucket_idx_t;
48 open_bucket_idx_t freelist;
49 open_bucket_idx_t hash;
52 * When an open bucket has an ec_stripe attached, this is the index of
53 * the block in the stripe this open_bucket corresponds to:
56 enum bch_data_type data_type:3;
58 unsigned on_partial_list:1;
61 unsigned sectors_free;
65 struct ec_stripe_new *ec;
68 #define OPEN_BUCKET_LIST_MAX 15
72 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
75 struct dev_stripe_state {
76 u64 next_alloc[BCH_SB_MEMBERS_MAX];
80 struct hlist_node node;
83 unsigned long write_point;
84 enum bch_data_type data_type;
86 /* calculated based on how many pointers we're actually going to use: */
87 unsigned sectors_free;
89 struct open_buckets ptrs;
90 struct dev_stripe_state stripe;
93 struct write_point_specifier {
97 struct alloc_heap_entry {
103 typedef HEAP(struct alloc_heap_entry) alloc_heap;
105 #endif /* _BCACHEFS_ALLOC_TYPES_H */