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"
14 RESERVE_BTREE_MOVINGGC = -2,
21 typedef FIFO(long) alloc_fifo;
23 #define OPEN_BUCKETS_COUNT 1024
25 #define WRITE_POINT_HASH_NR 32
26 #define WRITE_POINT_MAX 32
28 typedef u16 open_bucket_idx_t;
33 open_bucket_idx_t freelist;
36 * When an open bucket has an ec_stripe attached, this is the index of
37 * the block in the stripe this open_bucket corresponds to:
42 unsigned on_partial_list:1;
44 unsigned sectors_free;
45 struct bch_extent_ptr ptr;
46 struct ec_stripe_new *ec;
49 #define OPEN_BUCKET_LIST_MAX 15
53 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
56 struct dev_stripe_state {
57 u64 next_alloc[BCH_SB_MEMBERS_MAX];
61 struct hlist_node node;
64 unsigned long write_point;
65 enum bch_data_type type;
67 /* calculated based on how many pointers we're actually going to use: */
68 unsigned sectors_free;
70 struct open_buckets ptrs;
71 struct dev_stripe_state stripe;
74 struct write_point_specifier {
78 struct alloc_heap_entry {
84 typedef HEAP(struct alloc_heap_entry) alloc_heap;
86 #endif /* _BCACHEFS_ALLOC_TYPES_H */