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;
19 #define BCH_WATERMARKS() \
29 #define x(name) BCH_WATERMARK_##name,
35 #define BCH_WATERMARK_BITS 3
36 #define BCH_WATERMARK_MASK ~(~0U << BCH_WATERMARK_BITS)
38 #define OPEN_BUCKETS_COUNT 1024
40 #define WRITE_POINT_HASH_NR 32
41 #define WRITE_POINT_MAX 32
44 * 0 is never a valid open_bucket_idx_t:
46 typedef u16 open_bucket_idx_t;
51 open_bucket_idx_t freelist;
52 open_bucket_idx_t hash;
55 * When an open bucket has an ec_stripe attached, this is the index of
56 * the block in the stripe this open_bucket corresponds to:
59 enum bch_data_type data_type:6;
61 unsigned on_partial_list:1;
67 struct ec_stripe_new *ec;
70 #define OPEN_BUCKET_LIST_MAX 15
74 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
77 struct dev_stripe_state {
78 u64 next_alloc[BCH_SB_MEMBERS_MAX];
81 #define WRITE_POINT_STATES() \
87 enum write_point_state {
88 #define x(n) WRITE_POINT_##n,
96 struct hlist_node node;
99 unsigned long write_point;
100 enum bch_data_type data_type;
102 /* calculated based on how many pointers we're actually going to use: */
103 unsigned sectors_free;
105 struct open_buckets ptrs;
106 struct dev_stripe_state stripe;
108 u64 sectors_allocated;
109 } __aligned(SMP_CACHE_BYTES);
112 struct work_struct index_update_work;
114 struct list_head writes;
115 spinlock_t writes_lock;
117 enum write_point_state state;
118 u64 last_state_change;
119 u64 time[WRITE_POINT_STATE_NR];
120 } __aligned(SMP_CACHE_BYTES);
123 struct write_point_specifier {
127 #endif /* _BCACHEFS_ALLOC_TYPES_H */