67 lines
2.3 KiB
Diff
67 lines
2.3 KiB
Diff
From 247a12f3a216cb2368d596a152f0c32c2cb9d9c7 Mon Sep 17 00:00:00 2001
|
|
From: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Date: Fri, 29 Nov 2024 18:17:00 -0500
|
|
Subject: [PATCH 154/233] bcachefs: If we did repair on a btree node, make sure
|
|
we rewrite it
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Ensure that "invalid bkey" repair gets persisted, so that it doesn't
|
|
repeatedly spam the logs.
|
|
|
|
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
fs/bcachefs/btree_io.c | 19 ++++++++++++-------
|
|
1 file changed, 12 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
|
|
index eedcb2445b99..9df9fc1c5e2b 100644
|
|
--- a/fs/bcachefs/btree_io.c
|
|
+++ b/fs/bcachefs/btree_io.c
|
|
@@ -997,6 +997,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
|
|
got_good_key:
|
|
le16_add_cpu(&i->u64s, -next_good_key);
|
|
memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
|
|
+ set_btree_node_need_rewrite(b);
|
|
}
|
|
fsck_err:
|
|
printbuf_exit(&buf);
|
|
@@ -1259,6 +1260,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
|
memmove_u64s_down(k, bkey_p_next(k),
|
|
(u64 *) vstruct_end(i) - (u64 *) k);
|
|
set_btree_bset_end(b, b->set);
|
|
+ set_btree_node_need_rewrite(b);
|
|
continue;
|
|
}
|
|
if (ret)
|
|
@@ -1372,15 +1374,18 @@ static void btree_node_read_work(struct work_struct *work)
|
|
rb->start_time);
|
|
bio_put(&rb->bio);
|
|
|
|
- if (saw_error &&
|
|
+ if ((saw_error ||
|
|
+ btree_node_need_rewrite(b)) &&
|
|
!btree_node_read_error(b) &&
|
|
c->curr_recovery_pass != BCH_RECOVERY_PASS_scan_for_btree_nodes) {
|
|
- printbuf_reset(&buf);
|
|
- bch2_btree_id_level_to_text(&buf, b->c.btree_id, b->c.level);
|
|
- prt_str(&buf, " ");
|
|
- bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
|
|
- bch_err_ratelimited(c, "%s: rewriting btree node at due to error\n %s",
|
|
- __func__, buf.buf);
|
|
+ if (saw_error) {
|
|
+ printbuf_reset(&buf);
|
|
+ bch2_btree_id_level_to_text(&buf, b->c.btree_id, b->c.level);
|
|
+ prt_str(&buf, " ");
|
|
+ bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
|
|
+ bch_err_ratelimited(c, "%s: rewriting btree node at due to error\n %s",
|
|
+ __func__, buf.buf);
|
|
+ }
|
|
|
|
bch2_btree_node_rewrite_async(c, b);
|
|
}
|
|
--
|
|
2.45.2
|
|
|