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;
21 #define BCH_ALLOC_RESERVES() \
28 #define x(name) RESERVE_##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:8;
56 unsigned on_partial_list:1;
57 unsigned alloc_reserve:3;
63 struct ec_stripe_new *ec;
66 #define OPEN_BUCKET_LIST_MAX 15
70 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
73 struct dev_stripe_state {
74 u64 next_alloc[BCH_SB_MEMBERS_MAX];
78 struct hlist_node node;
81 unsigned long write_point;
82 enum bch_data_type data_type;
84 /* calculated based on how many pointers we're actually going to use: */
85 unsigned sectors_free;
87 struct open_buckets ptrs;
88 struct dev_stripe_state stripe;
90 struct work_struct index_update_work;
92 struct list_head writes;
93 spinlock_t writes_lock;
96 struct write_point_specifier {
100 #endif /* _BCACHEFS_ALLOC_TYPES_H */