Commit 08061519 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Don't ratelimit certain fsck errors

It's unhelpful if we see "Halting mark and sweep to start topology
repair" but we don't see the error that triggered it.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 33a1f84b
...@@ -86,12 +86,16 @@ static int bch2_gc_check_topology(struct bch_fs *c, ...@@ -86,12 +86,16 @@ static int bch2_gc_check_topology(struct bch_fs *c,
if (bpos_cmp(expected_start, bp->v.min_key)) { if (bpos_cmp(expected_start, bp->v.min_key)) {
bch2_topology_error(c); bch2_topology_error(c);
if (fsck_err(c, "btree node with incorrect min_key at btree %s level %u:\n" if (__fsck_err(c,
" prev %s\n" FSCK_CAN_FIX|
" cur %s", FSCK_CAN_IGNORE|
bch2_btree_ids[b->c.btree_id], b->c.level, FSCK_NO_RATELIMIT,
buf1, "btree node with incorrect min_key at btree %s level %u:\n"
(bch2_bkey_val_to_text(&PBUF(buf2), c, bkey_i_to_s_c(cur.k)), buf2))) { " prev %s\n"
" cur %s",
bch2_btree_ids[b->c.btree_id], b->c.level,
buf1,
(bch2_bkey_val_to_text(&PBUF(buf2), c, bkey_i_to_s_c(cur.k)), buf2))) {
bch_info(c, "Halting mark and sweep to start topology repair pass"); bch_info(c, "Halting mark and sweep to start topology repair pass");
return FSCK_ERR_START_TOPOLOGY_REPAIR; return FSCK_ERR_START_TOPOLOGY_REPAIR;
} else { } else {
...@@ -103,12 +107,16 @@ static int bch2_gc_check_topology(struct bch_fs *c, ...@@ -103,12 +107,16 @@ static int bch2_gc_check_topology(struct bch_fs *c,
if (is_last && bpos_cmp(cur.k->k.p, node_end)) { if (is_last && bpos_cmp(cur.k->k.p, node_end)) {
bch2_topology_error(c); bch2_topology_error(c);
if (fsck_err(c, "btree node with incorrect max_key at btree %s level %u:\n" if (__fsck_err(c,
" %s\n" FSCK_CAN_FIX|
" expected %s", FSCK_CAN_IGNORE|
bch2_btree_ids[b->c.btree_id], b->c.level, FSCK_NO_RATELIMIT,
(bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(cur.k)), buf1), "btree node with incorrect max_key at btree %s level %u:\n"
(bch2_bpos_to_text(&PBUF(buf2), node_end), buf2))) { " %s\n"
" expected %s",
bch2_btree_ids[b->c.btree_id], b->c.level,
(bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(cur.k)), buf1),
(bch2_bpos_to_text(&PBUF(buf2), node_end), buf2))) {
bch_info(c, "Halting mark and sweep to start topology repair pass"); bch_info(c, "Halting mark and sweep to start topology repair pass");
return FSCK_ERR_START_TOPOLOGY_REPAIR; return FSCK_ERR_START_TOPOLOGY_REPAIR;
} else { } else {
...@@ -884,11 +892,15 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b, ...@@ -884,11 +892,15 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b,
if (ret == -EIO) { if (ret == -EIO) {
bch2_topology_error(c); bch2_topology_error(c);
if (fsck_err(c, "Unreadable btree node at btree %s level %u:\n" if (__fsck_err(c,
" %s", FSCK_CAN_FIX|
bch2_btree_ids[b->c.btree_id], FSCK_CAN_IGNORE|
b->c.level - 1, FSCK_NO_RATELIMIT,
(bch2_bkey_val_to_text(&PBUF(buf), c, bkey_i_to_s_c(cur.k)), buf))) { "Unreadable btree node at btree %s level %u:\n"
" %s",
bch2_btree_ids[b->c.btree_id],
b->c.level - 1,
(bch2_bkey_val_to_text(&PBUF(buf), c, bkey_i_to_s_c(cur.k)), buf))) {
ret = FSCK_ERR_START_TOPOLOGY_REPAIR; ret = FSCK_ERR_START_TOPOLOGY_REPAIR;
bch_info(c, "Halting mark and sweep to start topology repair pass"); bch_info(c, "Halting mark and sweep to start topology repair pass");
goto fsck_err; goto fsck_err;
......
...@@ -111,6 +111,7 @@ enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags, ...@@ -111,6 +111,7 @@ enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags,
list_move(&s->list, &c->fsck_errors); list_move(&s->list, &c->fsck_errors);
s->nr++; s->nr++;
if (c->opts.ratelimit_errors && if (c->opts.ratelimit_errors &&
!(flags & FSCK_NO_RATELIMIT) &&
s->nr >= FSCK_ERR_RATELIMIT_NR) { s->nr >= FSCK_ERR_RATELIMIT_NR) {
if (s->nr == FSCK_ERR_RATELIMIT_NR) if (s->nr == FSCK_ERR_RATELIMIT_NR)
suppressing = true; suppressing = true;
......
...@@ -104,6 +104,7 @@ struct fsck_err_state { ...@@ -104,6 +104,7 @@ struct fsck_err_state {
#define FSCK_CAN_FIX (1 << 0) #define FSCK_CAN_FIX (1 << 0)
#define FSCK_CAN_IGNORE (1 << 1) #define FSCK_CAN_IGNORE (1 << 1)
#define FSCK_NEED_FSCK (1 << 2) #define FSCK_NEED_FSCK (1 << 2)
#define FSCK_NO_RATELIMIT (1 << 3)
__printf(3, 4) __cold __printf(3, 4) __cold
enum fsck_err_ret bch2_fsck_err(struct bch_fs *, enum fsck_err_ret bch2_fsck_err(struct bch_fs *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment