1 #ifndef _BCACHEFS_ALLOC_TYPES_H
2 #define _BCACHEFS_ALLOC_TYPES_H
4 #include <linux/mutex.h>
5 #include <linux/spinlock.h>
7 #include "clock_types.h"
12 /* There's two of these clocks, one for reads and one for writes: */
15 * "now" in (read/write) IO time - incremented whenever we do X amount
18 * Goes with the bucket read/write prios: when we read or write to a
19 * bucket we reset the bucket's prio to the current hand; thus hand -
20 * prio = time since bucket was last read/written.
22 * The units are some amount (bytes/sectors) of data read/written, and
23 * the units can change on the fly if we need to rescale to fit
24 * everything in a u16 - your only guarantee is that the units are
32 struct io_timer rescale;
36 /* There is one reserve for each type of btree, one for prios and gens
37 * and one for moving GC */
46 typedef FIFO(long) alloc_fifo;
48 /* Enough for 16 cache devices, 2 tiers and some left over for pipelining */
49 #define OPEN_BUCKETS_COUNT 256
51 #define WRITE_POINT_HASH_NR 32
52 #define WRITE_POINT_MAX 32
61 unsigned sectors_free;
62 struct bch_extent_ptr ptr;
63 struct ec_stripe_new *ec;
66 #define OPEN_BUCKET_LIST_MAX 15
70 u8 v[OPEN_BUCKET_LIST_MAX];
73 struct dev_stripe_state {
74 u64 next_alloc[BCH_SB_MEMBERS_MAX];
78 struct hlist_node node;
81 unsigned long write_point;
82 enum bch_data_type type;
85 /* calculated based on how many pointers we're actually going to use: */
86 unsigned sectors_free;
88 struct open_buckets ptrs;
89 struct dev_stripe_state stripe;
92 struct write_point_specifier {
96 struct alloc_heap_entry {
102 typedef HEAP(struct alloc_heap_entry) alloc_heap;
104 #endif /* _BCACHEFS_ALLOC_TYPES_H */