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"
13 #define BCH_ALLOC_RESERVES() \
20 #define x(name) RESERVE_##name,
25 #define OPEN_BUCKETS_COUNT 1024
27 #define WRITE_POINT_HASH_NR 32
28 #define WRITE_POINT_MAX 32
31 * 0 is never a valid open_bucket_idx_t:
33 typedef u16 open_bucket_idx_t;
38 open_bucket_idx_t freelist;
39 open_bucket_idx_t hash;
42 * When an open bucket has an ec_stripe attached, this is the index of
43 * the block in the stripe this open_bucket corresponds to:
46 enum bch_data_type data_type:3;
48 unsigned on_partial_list:1;
51 unsigned sectors_free;
55 struct ec_stripe_new *ec;
58 #define OPEN_BUCKET_LIST_MAX 15
62 open_bucket_idx_t v[OPEN_BUCKET_LIST_MAX];
65 struct dev_stripe_state {
66 u64 next_alloc[BCH_SB_MEMBERS_MAX];
70 struct hlist_node node;
73 unsigned long write_point;
74 enum bch_data_type data_type;
76 /* calculated based on how many pointers we're actually going to use: */
77 unsigned sectors_free;
79 struct open_buckets ptrs;
80 struct dev_stripe_state stripe;
83 struct write_point_specifier {
87 #endif /* _BCACHEFS_ALLOC_TYPES_H */