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"
11 struct bucket_alloc_state {
14 u64 skipped_need_journal_commit;
21 #define BCH_ALLOC_RESERVES() \
29 #define x(name) RESERVE_##name,
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:6;
58 unsigned on_partial_list:1;
64 struct ec_stripe_new *ec;
67 #define OPEN_BUCKET_LIST_MAX 15
71 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
74 struct dev_stripe_state {
75 u64 next_alloc[BCH_SB_MEMBERS_MAX];
78 #define WRITE_POINT_STATES() \
84 enum write_point_state {
85 #define x(n) WRITE_POINT_##n,
93 struct hlist_node node;
96 unsigned long write_point;
97 enum bch_data_type data_type;
99 /* calculated based on how many pointers we're actually going to use: */
100 unsigned sectors_free;
102 struct open_buckets ptrs;
103 struct dev_stripe_state stripe;
105 u64 sectors_allocated;
106 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
109 struct work_struct index_update_work;
111 struct list_head writes;
112 spinlock_t writes_lock;
114 enum write_point_state state;
115 u64 last_state_change;
116 u64 time[WRITE_POINT_STATE_NR];
117 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
120 struct write_point_specifier {
124 #endif /* _BCACHEFS_ALLOC_TYPES_H */