1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_JOURNAL_RECLAIM_H
3 #define _BCACHEFS_JOURNAL_RECLAIM_H
5 #define JOURNAL_PIN (32 * 1024)
7 enum journal_space_from {
8 journal_space_discarded,
9 journal_space_clean_ondisk,
13 unsigned bch2_journal_dev_buckets_available(struct journal *,
14 struct journal_device *,
15 enum journal_space_from);
16 void bch2_journal_space_available(struct journal *);
18 static inline bool journal_pin_active(struct journal_entry_pin *pin)
23 static inline struct journal_entry_pin_list *
24 journal_seq_pin(struct journal *j, u64 seq)
26 EBUG_ON(seq < j->pin.front || seq >= j->pin.back);
28 return &j->pin.data[seq & j->pin.mask];
31 void bch2_journal_pin_put(struct journal *, u64);
32 void bch2_journal_pin_drop(struct journal *, struct journal_entry_pin *);
34 void __bch2_journal_pin_add(struct journal *, u64, struct journal_entry_pin *,
35 journal_pin_flush_fn);
37 static inline void bch2_journal_pin_add(struct journal *j, u64 seq,
38 struct journal_entry_pin *pin,
39 journal_pin_flush_fn flush_fn)
41 if (unlikely(!journal_pin_active(pin)))
42 __bch2_journal_pin_add(j, seq, pin, flush_fn);
45 void bch2_journal_pin_copy(struct journal *,
46 struct journal_entry_pin *,
47 struct journal_entry_pin *,
48 journal_pin_flush_fn);
50 void bch2_journal_pin_flush(struct journal *, struct journal_entry_pin *);
52 void bch2_journal_do_discards(struct journal *);
53 void bch2_journal_reclaim(struct journal *);
54 void bch2_journal_reclaim_work(struct work_struct *);
56 void bch2_journal_flush_pins(struct journal *, u64);
58 static inline void bch2_journal_flush_all_pins(struct journal *j)
60 bch2_journal_flush_pins(j, U64_MAX);
63 int bch2_journal_flush_device_pins(struct journal *, int);
65 #endif /* _BCACHEFS_JOURNAL_RECLAIM_H */