summaryrefslogtreecommitdiff
path: root/libbcachefs/recovery_passes.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/recovery_passes.c')
-rw-r--r--libbcachefs/recovery_passes.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/libbcachefs/recovery_passes.c b/libbcachefs/recovery_passes.c
index 6a039e01..f9d1c492 100644
--- a/libbcachefs/recovery_passes.c
+++ b/libbcachefs/recovery_passes.c
@@ -237,19 +237,21 @@ static int bch2_lookup_root_inode(struct bch_fs *c)
subvol_inum inum = BCACHEFS_ROOT_SUBVOL_INUM;
struct bch_inode_unpacked inode_u;
struct bch_subvolume subvol;
+ CLASS(btree_trans, trans)(c);
- return bch2_trans_do(c,
+ return lockrestart_do(trans,
bch2_subvolume_get(trans, inum.subvol, true, &subvol) ?:
bch2_inode_find_by_inum_trans(trans, inum, &inode_u));
}
struct recovery_pass_fn {
int (*fn)(struct bch_fs *);
+ const char *name;
unsigned when;
};
static struct recovery_pass_fn recovery_pass_fns[] = {
-#define x(_fn, _id, _when) { .fn = bch2_##_fn, .when = _when },
+#define x(_fn, _id, _when) { .fn = bch2_##_fn, .name = #_fn, .when = _when },
BCH_RECOVERY_PASSES()
#undef x
};
@@ -346,13 +348,11 @@ int __bch2_run_explicit_recovery_pass(struct bch_fs *c,
lockdep_assert_held(&c->sb_lock);
bch2_printbuf_make_room(out, 1024);
- out->atomic++;
-
- unsigned long lockflags;
- spin_lock_irqsave(&r->lock, lockflags);
+ guard(printbuf_atomic)(out);
+ guard(spinlock_irq)(&r->lock);
if (!recovery_pass_needs_set(c, pass, &flags))
- goto out;
+ return 0;
bool in_recovery = test_bit(BCH_FS_in_recovery, &c->flags);
bool rewind = in_recovery &&
@@ -369,8 +369,7 @@ int __bch2_run_explicit_recovery_pass(struct bch_fs *c,
(!in_recovery || r->curr_pass >= BCH_RECOVERY_PASS_set_may_go_rw)) {
prt_printf(out, "need recovery pass %s (%u), but already rw\n",
bch2_recovery_passes[pass], pass);
- ret = bch_err_throw(c, cannot_rewind_recovery);
- goto out;
+ return bch_err_throw(c, cannot_rewind_recovery);
}
if (ratelimit)
@@ -400,9 +399,7 @@ int __bch2_run_explicit_recovery_pass(struct bch_fs *c,
if (p->when & PASS_ONLINE)
bch2_run_async_recovery_passes(c);
}
-out:
- spin_unlock_irqrestore(&r->lock, lockflags);
- --out->atomic;
+
return ret;
}
@@ -458,16 +455,14 @@ int bch2_run_print_explicit_recovery_pass(struct bch_fs *c, enum bch_recovery_pa
if (!recovery_pass_needs_set(c, pass, &flags))
return 0;
- struct printbuf buf = PRINTBUF;
+ CLASS(printbuf, buf)();
bch2_log_msg_start(c, &buf);
- mutex_lock(&c->sb_lock);
+ guard(mutex)(&c->sb_lock);
int ret = __bch2_run_explicit_recovery_pass(c, &buf, pass,
RUN_RECOVERY_PASS_nopersistent);
- mutex_unlock(&c->sb_lock);
bch2_print_str(c, KERN_NOTICE, buf.buf);
- printbuf_exit(&buf);
return ret;
}
@@ -486,6 +481,7 @@ static int bch2_run_recovery_pass(struct bch_fs *c, enum bch_recovery_pass pass)
r->passes_to_run &= ~BIT_ULL(pass);
if (ret) {
+ bch_err(c, "%s(): error %s", p->name, bch2_err_str(ret));
r->passes_failing |= BIT_ULL(pass);
return ret;
}