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 {
15 u64 skipped_need_journal_commit;
22 #define BCH_ALLOC_RESERVES() \
29 #define x(name) RESERVE_##name,
34 #define OPEN_BUCKETS_COUNT 1024
36 #define WRITE_POINT_HASH_NR 32
37 #define WRITE_POINT_MAX 32
40 * 0 is never a valid open_bucket_idx_t:
42 typedef u16 open_bucket_idx_t;
47 open_bucket_idx_t freelist;
48 open_bucket_idx_t hash;
51 * When an open bucket has an ec_stripe attached, this is the index of
52 * the block in the stripe this open_bucket corresponds to:
55 enum bch_data_type data_type:8;
57 unsigned on_partial_list:1;
58 unsigned alloc_reserve:3;
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];
80 struct hlist_node node;
83 unsigned long write_point;
84 enum bch_data_type data_type;
86 /* calculated based on how many pointers we're actually going to use: */
87 unsigned sectors_free;
89 struct open_buckets ptrs;
90 struct dev_stripe_state stripe;
91 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
94 struct work_struct index_update_work;
96 struct list_head writes;
97 spinlock_t writes_lock;
98 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
101 struct write_point_specifier {
105 #endif /* _BCACHEFS_ALLOC_TYPES_H */