xref: /linux/fs/bcachefs/recovery.h (revision eed4edda910fe34dfae8c6bfbcf57f4593a54295)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_RECOVERY_H
3 #define _BCACHEFS_RECOVERY_H
4 
5 extern const char * const bch2_recovery_passes[];
6 
7 u64 bch2_recovery_passes_to_stable(u64 v);
8 u64 bch2_recovery_passes_from_stable(u64 v);
9 
10 /*
11  * For when we need to rewind recovery passes and run a pass we skipped:
12  */
13 static inline int bch2_run_explicit_recovery_pass(struct bch_fs *c,
14 						  enum bch_recovery_pass pass)
15 {
16 	if (c->recovery_passes_explicit & BIT_ULL(pass))
17 		return 0;
18 
19 	bch_info(c, "running explicit recovery pass %s (%u), currently at %s (%u)",
20 		 bch2_recovery_passes[pass], pass,
21 		 bch2_recovery_passes[c->curr_recovery_pass], c->curr_recovery_pass);
22 
23 	c->recovery_passes_explicit |= BIT_ULL(pass);
24 
25 	if (c->curr_recovery_pass >= pass) {
26 		c->curr_recovery_pass = pass;
27 		c->recovery_passes_complete &= (1ULL << pass) >> 1;
28 		return -BCH_ERR_restart_recovery;
29 	} else {
30 		return 0;
31 	}
32 }
33 
34 int bch2_run_online_recovery_passes(struct bch_fs *);
35 u64 bch2_fsck_recovery_passes(void);
36 
37 int bch2_fs_recovery(struct bch_fs *);
38 int bch2_fs_initialize(struct bch_fs *);
39 
40 #endif /* _BCACHEFS_RECOVERY_H */
41