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() \
27 #define x(name) BCH_WATERMARK_##name,
33 #define OPEN_BUCKETS_COUNT 1024
35 #define WRITE_POINT_HASH_NR 32
36 #define WRITE_POINT_MAX 32
39 * 0 is never a valid open_bucket_idx_t:
41 typedef u16 open_bucket_idx_t;
46 open_bucket_idx_t freelist;
47 open_bucket_idx_t hash;
50 * When an open bucket has an ec_stripe attached, this is the index of
51 * the block in the stripe this open_bucket corresponds to:
54 enum bch_data_type data_type:6;
56 unsigned on_partial_list:1;
62 struct ec_stripe_new *ec;
65 #define OPEN_BUCKET_LIST_MAX 15
69 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
72 struct dev_stripe_state {
73 u64 next_alloc[BCH_SB_MEMBERS_MAX];
76 #define WRITE_POINT_STATES() \
82 enum write_point_state {
83 #define x(n) WRITE_POINT_##n,
91 struct hlist_node node;
94 unsigned long write_point;
95 enum bch_data_type data_type;
97 /* calculated based on how many pointers we're actually going to use: */
98 unsigned sectors_free;
100 struct open_buckets ptrs;
101 struct dev_stripe_state stripe;
103 u64 sectors_allocated;
104 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
107 struct work_struct index_update_work;
109 struct list_head writes;
110 spinlock_t writes_lock;
112 enum write_point_state state;
113 u64 last_state_change;
114 u64 time[WRITE_POINT_STATE_NR];
115 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
118 struct write_point_specifier {
122 #endif /* _BCACHEFS_ALLOC_TYPES_H */