Commit 5ab4beb7 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Don't scan for btree nodes when we can reconstruct

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 359571c3
...@@ -1535,6 +1535,20 @@ enum btree_id { ...@@ -1535,6 +1535,20 @@ enum btree_id {
BTREE_ID_NR BTREE_ID_NR
}; };
static inline bool btree_id_is_alloc(enum btree_id id)
{
switch (id) {
case BTREE_ID_alloc:
case BTREE_ID_backpointers:
case BTREE_ID_need_discard:
case BTREE_ID_freespace:
case BTREE_ID_bucket_gens:
return true;
default:
return false;
}
}
#define BTREE_MAX_DEPTH 4U #define BTREE_MAX_DEPTH 4U
/* Btree nodes */ /* Btree nodes */
......
...@@ -368,11 +368,16 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct ...@@ -368,11 +368,16 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
buf.buf)) { buf.buf)) {
bch2_btree_node_evict(trans, cur_k.k); bch2_btree_node_evict(trans, cur_k.k);
cur = NULL; cur = NULL;
ret = bch2_run_explicit_recovery_pass(c, BCH_RECOVERY_PASS_scan_for_btree_nodes) ?: ret = bch2_journal_key_delete(c, b->c.btree_id,
bch2_journal_key_delete(c, b->c.btree_id, b->c.level, cur_k.k->k.p);
b->c.level, cur_k.k->k.p);
if (ret) if (ret)
break; break;
if (!btree_id_is_alloc(b->c.btree_id)) {
ret = bch2_run_explicit_recovery_pass(c, BCH_RECOVERY_PASS_scan_for_btree_nodes);
if (ret)
break;
}
continue; continue;
} }
......
...@@ -133,6 +133,9 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca, ...@@ -133,6 +133,9 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
if (le64_to_cpu(bn->magic) != bset_magic(c)) if (le64_to_cpu(bn->magic) != bset_magic(c))
return; return;
if (btree_id_is_alloc(BTREE_NODE_ID(bn)))
return;
rcu_read_lock(); rcu_read_lock();
struct found_btree_node n = { struct found_btree_node n = {
.btree_id = BTREE_NODE_ID(bn), .btree_id = BTREE_NODE_ID(bn),
...@@ -290,7 +293,7 @@ static int handle_overwrites(struct bch_fs *c, ...@@ -290,7 +293,7 @@ static int handle_overwrites(struct bch_fs *c,
found_btree_node_to_text(&buf, c, n); found_btree_node_to_text(&buf, c, n);
bch_err(c, "%s", buf.buf); bch_err(c, "%s", buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
return -1; return -BCH_ERR_fsck_repair_unimplemented;
} }
} }
...@@ -436,6 +439,9 @@ bool bch2_btree_has_scanned_nodes(struct bch_fs *c, enum btree_id btree) ...@@ -436,6 +439,9 @@ bool bch2_btree_has_scanned_nodes(struct bch_fs *c, enum btree_id btree)
int bch2_get_scanned_nodes(struct bch_fs *c, enum btree_id btree, int bch2_get_scanned_nodes(struct bch_fs *c, enum btree_id btree,
unsigned level, struct bpos node_min, struct bpos node_max) unsigned level, struct bpos node_min, struct bpos node_max)
{ {
if (btree_id_is_alloc(btree))
return 0;
struct find_btree_nodes *f = &c->found_btree_nodes; struct find_btree_nodes *f = &c->found_btree_nodes;
int ret = bch2_run_explicit_recovery_pass(c, BCH_RECOVERY_PASS_scan_for_btree_nodes); int ret = bch2_run_explicit_recovery_pass(c, BCH_RECOVERY_PASS_scan_for_btree_nodes);
......
...@@ -47,20 +47,6 @@ void bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree) ...@@ -47,20 +47,6 @@ void bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)
} }
} }
static bool btree_id_is_alloc(enum btree_id id)
{
switch (id) {
case BTREE_ID_alloc:
case BTREE_ID_backpointers:
case BTREE_ID_need_discard:
case BTREE_ID_freespace:
case BTREE_ID_bucket_gens:
return true;
default:
return false;
}
}
/* for -o reconstruct_alloc: */ /* for -o reconstruct_alloc: */
static void bch2_reconstruct_alloc(struct bch_fs *c) static void bch2_reconstruct_alloc(struct bch_fs *c)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment