Skip to content

Commit 417f01e

Browse files
author
Kent Overstreet
committed
bcachefs: Error ratelimiting is no longer only during fsck
We now more often do repair automatically, without the user invoking fsck - and sometimes that can involve fixing lots of errors, so let's avoid flooding the dmesg log. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent aa6a591 commit 417f01e

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

fs/bcachefs/error.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ static struct fsck_err_state *fsck_err_get(struct bch_fs *c,
272272
{
273273
struct fsck_err_state *s;
274274

275-
if (!test_bit(BCH_FS_fsck_running, &c->flags))
276-
return NULL;
277-
278275
list_for_each_entry(s, &c->fsck_error_msgs, list)
279276
if (s->id == id) {
280277
/*
@@ -639,14 +636,14 @@ int __bch2_bkey_fsck_err(struct bch_fs *c,
639636
return ret;
640637
}
641638

642-
void bch2_flush_fsck_errs(struct bch_fs *c)
639+
static void __bch2_flush_fsck_errs(struct bch_fs *c, bool print)
643640
{
644641
struct fsck_err_state *s, *n;
645642

646643
mutex_lock(&c->fsck_error_msgs_lock);
647644

648645
list_for_each_entry_safe(s, n, &c->fsck_error_msgs, list) {
649-
if (s->ratelimited && s->last_msg)
646+
if (print && s->ratelimited && s->last_msg)
650647
bch_err(c, "Saw %llu errors like:\n %s", s->nr, s->last_msg);
651648

652649
list_del(&s->list);
@@ -657,6 +654,16 @@ void bch2_flush_fsck_errs(struct bch_fs *c)
657654
mutex_unlock(&c->fsck_error_msgs_lock);
658655
}
659656

657+
void bch2_flush_fsck_errs(struct bch_fs *c)
658+
{
659+
__bch2_flush_fsck_errs(c, true);
660+
}
661+
662+
void bch2_free_fsck_errs(struct bch_fs *c)
663+
{
664+
__bch2_flush_fsck_errs(c, false);
665+
}
666+
660667
int bch2_inum_offset_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
661668
subvol_inum inum, u64 offset)
662669
{

fs/bcachefs/error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ int __bch2_fsck_err(struct bch_fs *, struct btree_trans *,
9393
_flags, BCH_FSCK_ERR_##_err_type, __VA_ARGS__)
9494

9595
void bch2_flush_fsck_errs(struct bch_fs *);
96+
void bch2_free_fsck_errs(struct bch_fs *);
9697

9798
#define fsck_err_wrap(_do) \
9899
({ \

fs/bcachefs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static void __bch2_fs_free(struct bch_fs *c)
552552

553553
bch2_find_btree_nodes_exit(&c->found_btree_nodes);
554554
bch2_free_pending_node_rewrites(c);
555+
bch2_free_fsck_errs(c);
555556
bch2_fs_accounting_exit(c);
556557
bch2_fs_sb_errors_exit(c);
557558
bch2_fs_counters_exit(c);

0 commit comments

Comments
 (0)