85 lines
2.6 KiB
Diff
85 lines
2.6 KiB
Diff
From bb4ae1459d12972bad07e9197b13d0a3e3e782e0 Mon Sep 17 00:00:00 2001
|
|
From: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Date: Tue, 10 Dec 2024 13:23:47 -0500
|
|
Subject: [PATCH 196/233] bcachefs: Refactor c->opts.reconstruct_alloc
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Now handled in one place.
|
|
|
|
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
fs/bcachefs/recovery.c | 28 ++++++++++++----------------
|
|
1 file changed, 12 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
|
|
index a342744fd275..fbef6579d884 100644
|
|
--- a/fs/bcachefs/recovery.c
|
|
+++ b/fs/bcachefs/recovery.c
|
|
@@ -107,6 +107,12 @@ int bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)
|
|
return ret;
|
|
}
|
|
|
|
+static void kill_btree(struct bch_fs *c, enum btree_id btree)
|
|
+{
|
|
+ bch2_btree_id_root(c, btree)->alive = false;
|
|
+ bch2_shoot_down_journal_keys(c, btree, 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
+}
|
|
+
|
|
/* for -o reconstruct_alloc: */
|
|
static void bch2_reconstruct_alloc(struct bch_fs *c)
|
|
{
|
|
@@ -157,16 +163,9 @@ static void bch2_reconstruct_alloc(struct bch_fs *c)
|
|
bch2_write_super(c);
|
|
mutex_unlock(&c->sb_lock);
|
|
|
|
- bch2_shoot_down_journal_keys(c, BTREE_ID_alloc,
|
|
- 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
- bch2_shoot_down_journal_keys(c, BTREE_ID_backpointers,
|
|
- 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
- bch2_shoot_down_journal_keys(c, BTREE_ID_need_discard,
|
|
- 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
- bch2_shoot_down_journal_keys(c, BTREE_ID_freespace,
|
|
- 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
- bch2_shoot_down_journal_keys(c, BTREE_ID_bucket_gens,
|
|
- 0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);
|
|
+ for (unsigned i = 0; i < btree_id_nr_alive(c); i++)
|
|
+ if (btree_id_is_alloc(i))
|
|
+ kill_btree(c, i);
|
|
}
|
|
|
|
/*
|
|
@@ -573,9 +572,6 @@ static int read_btree_roots(struct bch_fs *c)
|
|
if (!r->alive)
|
|
continue;
|
|
|
|
- if (btree_id_is_alloc(i) && c->opts.reconstruct_alloc)
|
|
- continue;
|
|
-
|
|
printbuf_reset(&buf);
|
|
bch2_btree_id_level_to_text(&buf, i, r->level);
|
|
|
|
@@ -863,15 +859,15 @@ int bch2_fs_recovery(struct bch_fs *c)
|
|
c->journal_replay_seq_start = last_seq;
|
|
c->journal_replay_seq_end = blacklist_seq - 1;
|
|
|
|
- if (c->opts.reconstruct_alloc)
|
|
- bch2_reconstruct_alloc(c);
|
|
-
|
|
zero_out_btree_mem_ptr(&c->journal_keys);
|
|
|
|
ret = journal_replay_early(c, clean);
|
|
if (ret)
|
|
goto err;
|
|
|
|
+ if (c->opts.reconstruct_alloc)
|
|
+ bch2_reconstruct_alloc(c);
|
|
+
|
|
/*
|
|
* After an unclean shutdown, skip then next few journal sequence
|
|
* numbers as they may have been referenced by btree writes that
|
|
--
|
|
2.45.2
|
|
|