Skip to content

Commit 652dd65

Browse files
author
Kent Overstreet
committed
bcachefs: btree_root_unreadable_and_scan_found_nothing autofix for non data btrees
If loosing a btree won't cause data loss - i.e. it's an alloc btree, or we can easily reconstruct it - we shouldn't require user action to continue repair. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent c366b16 commit 652dd65

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

fs/bcachefs/btree_gc.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@
4747
#define DROP_PREV_NODE 11
4848
#define DID_FILL_FROM_SCAN 12
4949

50+
/*
51+
* Returns true if it's a btree we can easily reconstruct, or otherwise won't
52+
* cause data loss if it's missing:
53+
*/
54+
static bool btree_id_important(enum btree_id btree)
55+
{
56+
if (btree_id_is_alloc(btree))
57+
return false;
58+
59+
switch (btree) {
60+
case BTREE_ID_quotas:
61+
case BTREE_ID_snapshot_trees:
62+
case BTREE_ID_logged_ops:
63+
case BTREE_ID_rebalance_work:
64+
case BTREE_ID_subvolume_children:
65+
return false;
66+
default:
67+
return true;
68+
}
69+
}
70+
5071
static const char * const bch2_gc_phase_strs[] = {
5172
#define x(n) #n,
5273
GC_PHASES()
@@ -534,8 +555,10 @@ int bch2_check_topology(struct bch_fs *c)
534555
r->error = 0;
535556

536557
if (!bch2_btree_has_scanned_nodes(c, i)) {
537-
mustfix_fsck_err(trans, btree_root_unreadable_and_scan_found_nothing,
538-
"no nodes found for btree %s, continue?", buf.buf);
558+
__fsck_err(trans,
559+
FSCK_CAN_FIX|(!btree_id_important(i) ? FSCK_AUTOFIX : 0),
560+
btree_root_unreadable_and_scan_found_nothing,
561+
"no nodes found for btree %s, continue?", buf.buf);
539562
bch2_btree_root_alloc_fake_trans(trans, i, 0);
540563
} else {
541564
bch2_btree_root_alloc_fake_trans(trans, i, 1);

0 commit comments

Comments
 (0)