Skip to content

Commit d50d7a5

Browse files
author
Kent Overstreet
committed
bcachefs: Check for logged ops when clean
If we shut down successfully, there shouldn't be any logged ops to resume. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 1c0ee43 commit d50d7a5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

fs/bcachefs/logged_ops.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ static int resume_logged_op(struct btree_trans *trans, struct btree_iter *iter,
3737
const struct bch_logged_op_fn *fn = logged_op_fn(k.k->type);
3838
struct bkey_buf sk;
3939
u32 restart_count = trans->restart_count;
40+
struct printbuf buf = PRINTBUF;
41+
int ret = 0;
42+
43+
fsck_err_on(test_bit(BCH_FS_clean_recovery, &c->flags),
44+
trans, logged_op_but_clean,
45+
"filesystem marked as clean but have logged op\n%s",
46+
(bch2_bkey_val_to_text(&buf, c, k),
47+
buf.buf));
4048

4149
if (!fn)
4250
return 0;
@@ -47,8 +55,9 @@ static int resume_logged_op(struct btree_trans *trans, struct btree_iter *iter,
4755
fn->resume(trans, sk.k);
4856

4957
bch2_bkey_buf_exit(&sk, c);
50-
51-
return trans_was_restarted(trans, restart_count);
58+
fsck_err:
59+
printbuf_exit(&buf);
60+
return ret ?: trans_was_restarted(trans, restart_count);
5261
}
5362

5463
int bch2_resume_logged_ops(struct bch_fs *c)

fs/bcachefs/sb-errors_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ enum bch_fsck_flags {
294294
x(accounting_key_replicas_nr_required_bad, 279, FSCK_AUTOFIX) \
295295
x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \
296296
x(accounting_key_version_0, 282, FSCK_AUTOFIX) \
297-
x(MAX, 283, 0)
297+
x(logged_op_but_clean, 283, FSCK_AUTOFIX) \
298+
x(MAX, 284, 0)
298299

299300
enum bch_sb_error_id {
300301
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,

0 commit comments

Comments
 (0)