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