bcachefs: Add an option for fsck error ratelimiting
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
ef496cd268
commit
e2ee3eaab7
@ -64,7 +64,7 @@ void bch2_io_error(struct bch_dev *ca)
|
|||||||
enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags,
|
enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct fsck_err_state *s;
|
struct fsck_err_state *s = NULL;
|
||||||
va_list args;
|
va_list args;
|
||||||
bool fix = false, print = true, suppressing = false;
|
bool fix = false, print = true, suppressing = false;
|
||||||
char _buf[sizeof(s->buf)], *buf = _buf;
|
char _buf[sizeof(s->buf)], *buf = _buf;
|
||||||
@ -99,8 +99,13 @@ enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags,
|
|||||||
found:
|
found:
|
||||||
list_move(&s->list, &c->fsck_errors);
|
list_move(&s->list, &c->fsck_errors);
|
||||||
s->nr++;
|
s->nr++;
|
||||||
suppressing = s->nr == FSCK_ERR_RATELIMIT_NR;
|
if (c->opts.ratelimit_errors &&
|
||||||
print = s->nr <= FSCK_ERR_RATELIMIT_NR;
|
s->nr >= FSCK_ERR_RATELIMIT_NR) {
|
||||||
|
if (s->nr == FSCK_ERR_RATELIMIT_NR)
|
||||||
|
suppressing = true;
|
||||||
|
else
|
||||||
|
print = false;
|
||||||
|
}
|
||||||
buf = s->buf;
|
buf = s->buf;
|
||||||
print:
|
print:
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@ -156,7 +161,7 @@ void bch2_flush_fsck_errs(struct bch_fs *c)
|
|||||||
mutex_lock(&c->fsck_error_lock);
|
mutex_lock(&c->fsck_error_lock);
|
||||||
|
|
||||||
list_for_each_entry_safe(s, n, &c->fsck_errors, list) {
|
list_for_each_entry_safe(s, n, &c->fsck_errors, list) {
|
||||||
if (s->nr > FSCK_ERR_RATELIMIT_NR)
|
if (s->ratelimited)
|
||||||
bch_err(c, "Saw %llu errors like:\n %s", s->nr, s->buf);
|
bch_err(c, "Saw %llu errors like:\n %s", s->nr, s->buf);
|
||||||
|
|
||||||
list_del(&s->list);
|
list_del(&s->list);
|
||||||
|
@ -114,6 +114,7 @@ struct fsck_err_state {
|
|||||||
struct list_head list;
|
struct list_head list;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
u64 nr;
|
u64 nr;
|
||||||
|
bool ratelimited;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,6 +68,12 @@ enum opt_type {
|
|||||||
* - helptext
|
* - helptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
#define RATELIMIT_ERRORS true
|
||||||
|
#else
|
||||||
|
#define RATELIMIT_ERRORS false
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BCH_OPTS() \
|
#define BCH_OPTS() \
|
||||||
x(block_size, u16, \
|
x(block_size, u16, \
|
||||||
OPT_FORMAT, \
|
OPT_FORMAT, \
|
||||||
@ -227,6 +233,11 @@ enum opt_type {
|
|||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
NO_SB_OPT, false, \
|
NO_SB_OPT, false, \
|
||||||
NULL, "Fix errors during fsck without asking") \
|
NULL, "Fix errors during fsck without asking") \
|
||||||
|
x(ratelimit_errors, u8, \
|
||||||
|
OPT_MOUNT, \
|
||||||
|
OPT_BOOL(), \
|
||||||
|
NO_SB_OPT, RATELIMIT_ERRORS, \
|
||||||
|
NULL, "Ratelimit error messages during fsck") \
|
||||||
x(nochanges, u8, \
|
x(nochanges, u8, \
|
||||||
OPT_MOUNT, \
|
OPT_MOUNT, \
|
||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
|
Reference in New Issue
Block a user