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 {
20 u64 skipped_need_journal_commit;
21 u64 need_journal_commit;
24 u64 skipped_mi_btree_bitmap;
27 #define BCH_WATERMARKS() \
37 #define x(name) BCH_WATERMARK_##name,
43 #define BCH_WATERMARK_BITS 3
44 #define BCH_WATERMARK_MASK ~(~0U << BCH_WATERMARK_BITS)
46 #define OPEN_BUCKETS_COUNT 1024
48 #define WRITE_POINT_HASH_NR 32
49 #define WRITE_POINT_MAX 32
52 * 0 is never a valid open_bucket_idx_t:
54 typedef u16 open_bucket_idx_t;
59 open_bucket_idx_t freelist;
60 open_bucket_idx_t hash;
63 * When an open bucket has an ec_stripe attached, this is the index of
64 * the block in the stripe this open_bucket corresponds to:
67 enum bch_data_type data_type:6;
69 unsigned on_partial_list:1;
75 struct ec_stripe_new *ec;
78 #define OPEN_BUCKET_LIST_MAX 15
82 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
85 struct dev_stripe_state {
86 u64 next_alloc[BCH_SB_MEMBERS_MAX];
89 #define WRITE_POINT_STATES() \
95 enum write_point_state {
96 #define x(n) WRITE_POINT_##n,
104 struct hlist_node node;
107 unsigned long write_point;
108 enum bch_data_type data_type;
110 /* calculated based on how many pointers we're actually going to use: */
111 unsigned sectors_free;
113 struct open_buckets ptrs;
114 struct dev_stripe_state stripe;
116 u64 sectors_allocated;
117 } __aligned(SMP_CACHE_BYTES);
120 struct work_struct index_update_work;
122 struct list_head writes;
123 spinlock_t writes_lock;
125 enum write_point_state state;
126 u64 last_state_change;
127 u64 time[WRITE_POINT_STATE_NR];
128 } __aligned(SMP_CACHE_BYTES);
131 struct write_point_specifier {
135 #endif /* _BCACHEFS_ALLOC_TYPES_H */