Skip to content

Commit 060ff30

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_run_explicit_recovery_pass_persistent()
Flag that we need to run a recovery pass and run it - persistenly, so if we crash it'll still get run. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 0a34c05 commit 060ff30

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

fs/bcachefs/recovery_passes.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "snapshot.h"
1717
#include "subvolume.h"
1818
#include "super.h"
19+
#include "super-io.h"
1920

2021
const char * const bch2_recovery_passes[] = {
2122
#define x(_fn, ...) #_fn,
@@ -112,6 +113,23 @@ int bch2_run_explicit_recovery_pass(struct bch_fs *c,
112113
}
113114
}
114115

116+
int bch2_run_explicit_recovery_pass_persistent(struct bch_fs *c,
117+
enum bch_recovery_pass pass)
118+
{
119+
__le64 s = cpu_to_le64(bch2_recovery_passes_to_stable(BIT_ULL(pass)));
120+
121+
mutex_lock(&c->sb_lock);
122+
struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext);
123+
124+
if (!(ext->recovery_passes_required[0] & s)) {
125+
ext->recovery_passes_required[0] |= s;
126+
bch2_write_super(c);
127+
}
128+
mutex_unlock(&c->sb_lock);
129+
130+
return bch2_run_explicit_recovery_pass(c, pass);
131+
}
132+
115133
u64 bch2_fsck_recovery_passes(void)
116134
{
117135
u64 ret = 0;

fs/bcachefs/recovery_passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ u64 bch2_recovery_passes_from_stable(u64 v);
99
u64 bch2_fsck_recovery_passes(void);
1010

1111
int bch2_run_explicit_recovery_pass(struct bch_fs *, enum bch_recovery_pass);
12+
int bch2_run_explicit_recovery_pass_persistent(struct bch_fs *, enum bch_recovery_pass);
1213

1314
int bch2_run_online_recovery_passes(struct bch_fs *);
1415
int bch2_run_recovery_passes(struct bch_fs *);

0 commit comments

Comments
 (0)