2017-03-16 22:18:50 -08:00
/* SPDX-License-Identifier: GPL-2.0 */
# ifndef _BCACHEFS_RECOVERY_H
# define _BCACHEFS_RECOVERY_H
2019-07-12 17:08:32 -04:00
struct journal_iter {
2021-01-26 20:15:46 -05:00
struct list_head list ;
2020-03-15 23:29:43 -04:00
enum btree_id btree_id ;
unsigned level ;
2021-01-26 20:15:46 -05:00
size_t idx ;
2019-07-12 17:08:32 -04:00
struct journal_keys * keys ;
} ;
2020-03-15 23:29:43 -04:00
/*
* Iterate over keys in the btree , with keys from the journal overlaid on top :
*/
2019-12-27 20:51:35 -05:00
2020-03-15 23:29:43 -04:00
struct btree_and_journal_iter {
struct btree * b ;
struct btree_node_iter node_iter ;
struct bkey unpacked ;
2019-12-27 20:51:35 -05:00
struct journal_iter journal ;
2022-06-06 21:59:34 -04:00
struct bpos pos ;
bool at_end ;
2019-12-27 20:51:35 -05:00
} ;
2022-04-11 20:28:13 -04:00
struct bkey_i * bch2_journal_keys_peek_upto ( struct bch_fs * , enum btree_id ,
2022-05-21 13:10:39 -04:00
unsigned , struct bpos , struct bpos , size_t * ) ;
2022-04-11 20:28:13 -04:00
struct bkey_i * bch2_journal_keys_peek_slot ( struct bch_fs * , enum btree_id ,
unsigned , struct bpos ) ;
2021-12-25 20:07:00 -05:00
2021-12-23 21:35:28 -05:00
int bch2_journal_key_insert_take ( struct bch_fs * , enum btree_id ,
unsigned , struct bkey_i * ) ;
2021-01-26 20:15:46 -05:00
int bch2_journal_key_insert ( struct bch_fs * , enum btree_id ,
unsigned , struct bkey_i * ) ;
int bch2_journal_key_delete ( struct bch_fs * , enum btree_id ,
unsigned , struct bpos ) ;
2021-12-31 17:54:13 -05:00
void bch2_journal_key_overwritten ( struct bch_fs * , enum btree_id ,
unsigned , struct bpos ) ;
2021-01-26 20:15:46 -05:00
2019-12-27 20:51:35 -05:00
void bch2_btree_and_journal_iter_advance ( struct btree_and_journal_iter * ) ;
struct bkey_s_c bch2_btree_and_journal_iter_peek ( struct btree_and_journal_iter * ) ;
2020-03-15 23:29:43 -04:00
2021-01-26 20:15:46 -05:00
void bch2_btree_and_journal_iter_exit ( struct btree_and_journal_iter * ) ;
2021-12-25 20:07:00 -05:00
void __bch2_btree_and_journal_iter_init_node_iter ( struct btree_and_journal_iter * ,
struct bch_fs * , struct btree * ,
struct btree_node_iter , struct bpos ) ;
2020-03-15 23:29:43 -04:00
void bch2_btree_and_journal_iter_init_node_iter ( struct btree_and_journal_iter * ,
2021-01-26 20:15:46 -05:00
struct bch_fs * ,
2020-03-15 23:29:43 -04:00
struct btree * ) ;
2019-07-12 17:08:32 -04:00
2020-03-25 16:12:33 -04:00
void bch2_journal_keys_free ( struct journal_keys * ) ;
2022-03-21 00:15:53 -04:00
void bch2_journal_entries_free ( struct bch_fs * ) ;
2020-03-25 16:12:33 -04:00
2017-03-16 22:18:50 -08:00
int bch2_fs_recovery ( struct bch_fs * ) ;
int bch2_fs_initialize ( struct bch_fs * ) ;
# endif /* _BCACHEFS_RECOVERY_H */