2017-03-16 23:18:50 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_JOURNAL_RECLAIM_H
|
|
|
|
#define _BCACHEFS_JOURNAL_RECLAIM_H
|
|
|
|
|
|
|
|
#define JOURNAL_PIN (32 * 1024)
|
|
|
|
|
2020-11-19 18:55:33 -07:00
|
|
|
static inline void journal_reclaim_kick(struct journal *j)
|
|
|
|
{
|
|
|
|
struct task_struct *p = READ_ONCE(j->reclaim_thread);
|
|
|
|
|
2021-04-28 19:12:07 -07:00
|
|
|
j->reclaim_kicked = true;
|
|
|
|
if (p)
|
|
|
|
wake_up_process(p);
|
2020-11-19 18:55:33 -07:00
|
|
|
}
|
|
|
|
|
2019-02-21 11:33:21 -07:00
|
|
|
unsigned bch2_journal_dev_buckets_available(struct journal *,
|
2019-03-03 14:50:40 -07:00
|
|
|
struct journal_device *,
|
|
|
|
enum journal_space_from);
|
2023-11-02 15:57:19 -07:00
|
|
|
void bch2_journal_set_watermark(struct journal *);
|
2019-02-21 11:33:21 -07:00
|
|
|
void bch2_journal_space_available(struct journal *);
|
|
|
|
|
2017-03-16 23:18:50 -07:00
|
|
|
static inline bool journal_pin_active(struct journal_entry_pin *pin)
|
|
|
|
{
|
2018-07-17 09:19:14 -07:00
|
|
|
return pin->seq != 0;
|
2017-03-16 23:18:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct journal_entry_pin_list *
|
|
|
|
journal_seq_pin(struct journal *j, u64 seq)
|
|
|
|
{
|
2018-07-17 09:19:14 -07:00
|
|
|
EBUG_ON(seq < j->pin.front || seq >= j->pin.back);
|
2017-03-16 23:18:50 -07:00
|
|
|
|
|
|
|
return &j->pin.data[seq & j->pin.mask];
|
|
|
|
}
|
|
|
|
|
2023-09-15 05:51:51 -07:00
|
|
|
void bch2_journal_reclaim_fast(struct journal *);
|
|
|
|
bool __bch2_journal_pin_put(struct journal *, u64);
|
2019-02-21 11:33:21 -07:00
|
|
|
void bch2_journal_pin_put(struct journal *, u64);
|
2017-03-16 23:18:50 -07:00
|
|
|
void bch2_journal_pin_drop(struct journal *, struct journal_entry_pin *);
|
2020-02-27 13:03:44 -07:00
|
|
|
|
2020-12-01 09:48:08 -07:00
|
|
|
void bch2_journal_pin_set(struct journal *, u64, struct journal_entry_pin *,
|
|
|
|
journal_pin_flush_fn);
|
2020-02-27 13:03:44 -07:00
|
|
|
|
|
|
|
static inline void bch2_journal_pin_add(struct journal *j, u64 seq,
|
|
|
|
struct journal_entry_pin *pin,
|
|
|
|
journal_pin_flush_fn flush_fn)
|
|
|
|
{
|
2020-05-25 11:57:06 -07:00
|
|
|
if (unlikely(!journal_pin_active(pin) || pin->seq > seq))
|
2020-12-01 09:48:08 -07:00
|
|
|
bch2_journal_pin_set(j, seq, pin, flush_fn);
|
2020-02-27 13:03:44 -07:00
|
|
|
}
|
|
|
|
|
2023-11-07 10:32:50 -07:00
|
|
|
void bch2_journal_pin_copy(struct journal *,
|
|
|
|
struct journal_entry_pin *,
|
|
|
|
struct journal_entry_pin *,
|
|
|
|
journal_pin_flush_fn);
|
2019-03-07 17:46:10 -07:00
|
|
|
|
2020-12-01 09:48:08 -07:00
|
|
|
static inline void bch2_journal_pin_update(struct journal *j, u64 seq,
|
|
|
|
struct journal_entry_pin *pin,
|
|
|
|
journal_pin_flush_fn flush_fn)
|
|
|
|
{
|
|
|
|
if (unlikely(!journal_pin_active(pin) || pin->seq < seq))
|
|
|
|
bch2_journal_pin_set(j, seq, pin, flush_fn);
|
|
|
|
}
|
2020-02-27 13:03:44 -07:00
|
|
|
|
2018-07-17 09:19:14 -07:00
|
|
|
void bch2_journal_pin_flush(struct journal *, struct journal_entry_pin *);
|
2017-03-16 23:18:50 -07:00
|
|
|
|
2019-03-03 16:39:07 -07:00
|
|
|
void bch2_journal_do_discards(struct journal *);
|
2020-12-03 11:23:58 -07:00
|
|
|
int bch2_journal_reclaim(struct journal *);
|
2020-11-19 18:55:33 -07:00
|
|
|
|
|
|
|
void bch2_journal_reclaim_stop(struct journal *);
|
|
|
|
int bch2_journal_reclaim_start(struct journal *);
|
2017-03-16 23:18:50 -07:00
|
|
|
|
2020-05-28 13:06:13 -07:00
|
|
|
bool bch2_journal_flush_pins(struct journal *, u64);
|
2017-03-16 23:18:50 -07:00
|
|
|
|
2020-05-28 13:06:13 -07:00
|
|
|
static inline bool bch2_journal_flush_all_pins(struct journal *j)
|
2017-03-16 23:18:50 -07:00
|
|
|
{
|
2020-05-28 13:06:13 -07:00
|
|
|
return bch2_journal_flush_pins(j, U64_MAX);
|
2017-03-16 23:18:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int bch2_journal_flush_device_pins(struct journal *, int);
|
|
|
|
|
|
|
|
#endif /* _BCACHEFS_JOURNAL_RECLAIM_H */
|