1 #ifndef _BCACHEFS_RECOVERY_PASSES_H
2 #define _BCACHEFS_RECOVERY_PASSES_H
3
4 extern const char * const bch2_recovery_passes[];
5
6 extern const struct bch_sb_field_ops bch_sb_field_ops_recovery_passes;
7
8 u64 bch2_recovery_passes_to_stable(u64 v);
9 u64 bch2_recovery_passes_from_stable(u64 v);
10
11 u64 bch2_fsck_recovery_passes(void);
12
13 void bch2_recovery_pass_set_no_ratelimit(struct bch_fs *, enum bch_recovery_pass);
14
15 enum bch_run_recovery_pass_flags {
16 RUN_RECOVERY_PASS_nopersistent = BIT(0),
17 RUN_RECOVERY_PASS_ratelimit = BIT(1),
18 };
19
go_rw_in_recovery(struct bch_fs * c)20 static inline bool go_rw_in_recovery(struct bch_fs *c)
21 {
22 return (c->journal_keys.nr ||
23 !c->opts.read_only ||
24 !c->sb.clean ||
25 c->opts.recovery_passes ||
26 (c->opts.fsck && !(c->sb.features & BIT_ULL(BCH_FEATURE_no_alloc_info))));
27 }
28
29 int bch2_run_print_explicit_recovery_pass(struct bch_fs *, enum bch_recovery_pass);
30
31 int __bch2_run_explicit_recovery_pass(struct bch_fs *, struct printbuf *,
32 enum bch_recovery_pass,
33 enum bch_run_recovery_pass_flags);
34 int bch2_run_explicit_recovery_pass(struct bch_fs *, struct printbuf *,
35 enum bch_recovery_pass,
36 enum bch_run_recovery_pass_flags);
37
38 int bch2_require_recovery_pass(struct bch_fs *, struct printbuf *,
39 enum bch_recovery_pass);
40
41 int bch2_run_online_recovery_passes(struct bch_fs *, u64);
42 int bch2_run_recovery_passes(struct bch_fs *, enum bch_recovery_pass);
43
44 void bch2_recovery_pass_status_to_text(struct printbuf *, struct bch_fs *);
45
46 void bch2_fs_recovery_passes_init(struct bch_fs *);
47
48 #endif /* _BCACHEFS_RECOVERY_PASSES_H */
49