1 #ifndef _BCACHEFS_ALLOC_BACKGROUND_H
2 #define _BCACHEFS_ALLOC_BACKGROUND_H
5 #include "alloc_types.h"
8 #define ALLOC_SCAN_BATCH(ca) max_t(size_t, 1, (ca)->mi.nbuckets >> 9)
10 const char *bch2_alloc_invalid(const struct bch_fs *, struct bkey_s_c);
11 void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
13 #define bch2_bkey_ops_alloc (struct bkey_ops) { \
14 .key_invalid = bch2_alloc_invalid, \
15 .val_to_text = bch2_alloc_to_text, \
18 int bch2_alloc_read(struct bch_fs *, struct list_head *);
19 int bch2_alloc_replay_key(struct bch_fs *, struct bkey_i *);
21 static inline void bch2_wake_allocator(struct bch_dev *ca)
23 struct task_struct *p;
26 p = rcu_dereference(ca->alloc_thread);
32 static inline void verify_not_on_freelist(struct bch_fs *c, struct bch_dev *ca,
35 if (expensive_debug_checks(c) &&
36 test_bit(BCH_FS_ALLOCATOR_STARTED, &c->flags)) {
41 for (j = 0; j < RESERVE_NR; j++)
42 fifo_for_each_entry(i, &ca->free[j], iter)
44 fifo_for_each_entry(i, &ca->free_inc, iter)
49 void bch2_recalc_capacity(struct bch_fs *);
51 void bch2_dev_allocator_remove(struct bch_fs *, struct bch_dev *);
52 void bch2_dev_allocator_add(struct bch_fs *, struct bch_dev *);
54 void bch2_dev_allocator_stop(struct bch_dev *);
55 int bch2_dev_allocator_start(struct bch_dev *);
57 int bch2_alloc_write(struct bch_fs *);
58 int bch2_fs_allocator_start(struct bch_fs *);
59 void bch2_fs_allocator_background_init(struct bch_fs *);
61 #endif /* _BCACHEFS_ALLOC_BACKGROUND_H */