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
{
20 u64 skipped_need_journal_commit
;
23 u64 skipped_mi_btree_bitmap
;
26 #define BCH_WATERMARKS() \
36 #define x(name) BCH_WATERMARK_##name,
42 #define BCH_WATERMARK_BITS 3
43 #define BCH_WATERMARK_MASK ~(~0U << BCH_WATERMARK_BITS)
45 #define OPEN_BUCKETS_COUNT 1024
47 #define WRITE_POINT_HASH_NR 32
48 #define WRITE_POINT_MAX 32
51 * 0 is never a valid open_bucket_idx_t:
53 typedef u16 open_bucket_idx_t
;
58 open_bucket_idx_t freelist
;
59 open_bucket_idx_t hash
;
62 * When an open bucket has an ec_stripe attached, this is the index of
63 * the block in the stripe this open_bucket corresponds to:
66 enum bch_data_type data_type
:6;
68 unsigned on_partial_list
:1;
74 struct ec_stripe_new
*ec
;
77 #define OPEN_BUCKET_LIST_MAX 15
81 open_bucket_idx_t v
[OPEN_BUCKET_LIST_MAX
];
84 struct dev_stripe_state
{
85 u64 next_alloc
[BCH_SB_MEMBERS_MAX
];
88 #define WRITE_POINT_STATES() \
94 enum write_point_state
{
95 #define x(n) WRITE_POINT_##n,
103 struct hlist_node node
;
106 unsigned long write_point
;
107 enum bch_data_type data_type
;
109 /* calculated based on how many pointers we're actually going to use: */
110 unsigned sectors_free
;
112 struct open_buckets ptrs
;
113 struct dev_stripe_state stripe
;
115 u64 sectors_allocated
;
116 } __aligned(SMP_CACHE_BYTES
);
119 struct work_struct index_update_work
;
121 struct list_head writes
;
122 spinlock_t writes_lock
;
124 enum write_point_state state
;
125 u64 last_state_change
;
126 u64 time
[WRITE_POINT_STATE_NR
];
127 } __aligned(SMP_CACHE_BYTES
);
130 struct write_point_specifier
{
134 #endif /* _BCACHEFS_ALLOC_TYPES_H */