Skip to content

Commit 32a01cd

Browse files
author
Kent Overstreet
committed
bcachefs: Don't log fsck err in the journal if doing repair elsewhere
This fixes exceeding the bump allocator limit when the allocator finds many buckets that need repair - they're repaired asynchronously, which means that every error logged a message in the bump allocator, without committing. Signed-off-by: Kent Overstreet <[email protected]>
1 parent b2348fe commit 32a01cd

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,9 @@ int bch2_check_discard_freespace_key(struct btree_trans *trans, struct btree_ite
14061406
: BCH_DATA_free;
14071407
struct printbuf buf = PRINTBUF;
14081408

1409+
unsigned fsck_flags = (async_repair ? FSCK_ERR_NO_LOG : 0)|
1410+
FSCK_CAN_FIX|FSCK_CAN_IGNORE;
1411+
14091412
struct bpos bucket = iter->pos;
14101413
bucket.offset &= ~(~0ULL << 56);
14111414
u64 genbits = iter->pos.offset & (~0ULL << 56);
@@ -1419,9 +1422,10 @@ int bch2_check_discard_freespace_key(struct btree_trans *trans, struct btree_ite
14191422
return ret;
14201423

14211424
if (!bch2_dev_bucket_exists(c, bucket)) {
1422-
if (fsck_err(trans, need_discard_freespace_key_to_invalid_dev_bucket,
1423-
"entry in %s btree for nonexistant dev:bucket %llu:%llu",
1424-
bch2_btree_id_str(iter->btree_id), bucket.inode, bucket.offset))
1425+
if (__fsck_err(trans, fsck_flags,
1426+
need_discard_freespace_key_to_invalid_dev_bucket,
1427+
"entry in %s btree for nonexistant dev:bucket %llu:%llu",
1428+
bch2_btree_id_str(iter->btree_id), bucket.inode, bucket.offset))
14251429
goto delete;
14261430
ret = 1;
14271431
goto out;
@@ -1433,7 +1437,8 @@ int bch2_check_discard_freespace_key(struct btree_trans *trans, struct btree_ite
14331437
if (a->data_type != state ||
14341438
(state == BCH_DATA_free &&
14351439
genbits != alloc_freespace_genbits(*a))) {
1436-
if (fsck_err(trans, need_discard_freespace_key_bad,
1440+
if (__fsck_err(trans, fsck_flags,
1441+
need_discard_freespace_key_bad,
14371442
"%s\nincorrectly set at %s:%llu:%llu:0 (free %u, genbits %llu should be %llu)",
14381443
(bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf),
14391444
bch2_btree_id_str(iter->btree_id),

fs/bcachefs/btree_iter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,10 @@ void *__bch2_trans_kmalloc(struct btree_trans *trans, size_t size, unsigned long
31943194
if (WARN_ON_ONCE(new_bytes > BTREE_TRANS_MEM_MAX)) {
31953195
#ifdef CONFIG_BCACHEFS_TRANS_KMALLOC_TRACE
31963196
struct printbuf buf = PRINTBUF;
3197+
bch2_log_msg_start(c, &buf);
3198+
prt_printf(&buf, "bump allocator exceeded BTREE_TRANS_MEM_MAX (%u)\n",
3199+
BTREE_TRANS_MEM_MAX);
3200+
31973201
bch2_trans_kmalloc_trace_to_text(&buf, &trans->trans_kmalloc_trace);
31983202
bch2_print_str(c, KERN_ERR, buf.buf);
31993203
printbuf_exit(&buf);

fs/bcachefs/error.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,9 @@ int __bch2_fsck_err(struct bch_fs *c,
621621
if (s)
622622
s->ret = ret;
623623

624-
if (trans)
624+
if (trans &&
625+
!(flags & FSCK_ERR_NO_LOG) &&
626+
ret == -BCH_ERR_fsck_fix)
625627
ret = bch2_trans_log_str(trans, bch2_sb_error_strs[err]) ?: ret;
626628
err_unlock:
627629
mutex_unlock(&c->fsck_error_msgs_lock);

fs/bcachefs/sb-errors_format.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
#define _BCACHEFS_SB_ERRORS_FORMAT_H
44

55
enum bch_fsck_flags {
6-
FSCK_CAN_FIX = 1 << 0,
7-
FSCK_CAN_IGNORE = 1 << 1,
8-
FSCK_AUTOFIX = 1 << 2,
6+
FSCK_CAN_FIX = BIT(0),
7+
FSCK_CAN_IGNORE = BIT(1),
8+
FSCK_AUTOFIX = BIT(2),
9+
FSCK_ERR_NO_LOG = BIT(3),
910
};
1011

1112
#define BCH_SB_ERRS() \

0 commit comments

Comments
 (0)