Commit 652dd655 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c366b167
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -47,6 +47,27 @@
#define DROP_PREV_NODE		11
#define DID_FILL_FROM_SCAN	12

/*
 * Returns true if it's a btree we can easily reconstruct, or otherwise won't
 * cause data loss if it's missing:
 */
static bool btree_id_important(enum btree_id btree)
{
	if (btree_id_is_alloc(btree))
		return false;

	switch (btree) {
	case BTREE_ID_quotas:
	case BTREE_ID_snapshot_trees:
	case BTREE_ID_logged_ops:
	case BTREE_ID_rebalance_work:
	case BTREE_ID_subvolume_children:
		return false;
	default:
		return true;
	}
}

static const char * const bch2_gc_phase_strs[] = {
#define x(n)	#n,
	GC_PHASES()
@@ -534,7 +555,9 @@ int bch2_check_topology(struct bch_fs *c)
			r->error = 0;

			if (!bch2_btree_has_scanned_nodes(c, i)) {
				mustfix_fsck_err(trans, btree_root_unreadable_and_scan_found_nothing,
				__fsck_err(trans,
					   FSCK_CAN_FIX|(!btree_id_important(i) ? FSCK_AUTOFIX : 0),
					   btree_root_unreadable_and_scan_found_nothing,
					   "no nodes found for btree %s, continue?", buf.buf);
				bch2_btree_root_alloc_fake_trans(trans, i, 0);
			} else {