gentoo-overlay/sys-kernel/hardened-kernel/files/linux-6.12/0186-bcachefs-Don-t-start-r...

36 lines
1.4 KiB
Diff

From 0939c611cef4c7f917295a42dfbd2f56bc249a34 Mon Sep 17 00:00:00 2001
From: Kent Overstreet <kent.overstreet@linux.dev>
Date: Mon, 9 Dec 2024 06:00:33 -0500
Subject: [PATCH 186/233] bcachefs: Don't start rewriting btree nodes until
after journal replay
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
This fixes a deadlock during journal replay when btree node read errors
kick off a ton of rewrites: we don't want them competing with journal
replay.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
fs/bcachefs/btree_update_interior.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c
index 7d9dab95bdcf..03a6eba7403d 100644
--- a/fs/bcachefs/btree_update_interior.c
+++ b/fs/bcachefs/btree_update_interior.c
@@ -2291,7 +2291,8 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b)
bool now = false, pending = false;
spin_lock(&c->btree_node_rewrites_lock);
- if (bch2_write_ref_tryget(c, BCH_WRITE_REF_node_rewrite)) {
+ if (c->curr_recovery_pass > BCH_RECOVERY_PASS_journal_replay &&
+ bch2_write_ref_tryget(c, BCH_WRITE_REF_node_rewrite)) {
list_add(&a->list, &c->btree_node_rewrites);
now = true;
} else if (!test_bit(BCH_FS_may_go_rw, &c->flags)) {
--
2.45.2