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