gentoo-overlay/sys-kernel/hardened-kernel/files/linux-6.12/0135-bcachefs-Issue-a-transaction-restart-after-commit-in.patch
Alexander Miroshnichenko ad7c6fc00a
sys-kernel/hardened-kernel: bump v6.12.6
bcachefs patches synced to ca2e7a3de895c703d2cbbd9b63c10d8adfba8228 from master branch

Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
2024-12-20 17:26:34 +03:00

54 lines
2.0 KiB
Diff

From 6248d420a98583d960b736bec0fc52d1a4134894 Mon Sep 17 00:00:00 2001
From: Kent Overstreet <kent.overstreet@linux.dev>
Date: Wed, 27 Nov 2024 22:09:29 -0500
Subject: [PATCH 135/233] bcachefs: Issue a transaction restart after commit in
repair
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
transaction commits invalidate pointers to btree values, and they also
downgrade intent locks.
This breaks the interior btree update path, which takes intent locks and
then calls into the allocator.
This isn't an ideal solution: we can't unconditionally issue a restart
after a transaction commit, because that would break other codepaths.
Reported-by: syzbot+78d82470c16a49702682@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
fs/bcachefs/alloc_background.c | 2 +-
fs/bcachefs/errcode.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 8846daaa1162..79af226ca609 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -1384,7 +1384,7 @@ int bch2_check_discard_freespace_key(struct btree_trans *trans, struct btree_ite
ret = bch2_btree_bit_mod_iter(trans, iter, false) ?:
bch2_trans_commit(trans, NULL, NULL,
BCH_TRANS_COMMIT_no_enospc) ?:
- 1;
+ -BCH_ERR_transaction_restart_commit;
goto out;
}
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index a12050e9c191..a0cfc0f286f4 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -148,6 +148,7 @@
x(BCH_ERR_transaction_restart, transaction_restart_split_race) \
x(BCH_ERR_transaction_restart, transaction_restart_write_buffer_flush) \
x(BCH_ERR_transaction_restart, transaction_restart_nested) \
+ x(BCH_ERR_transaction_restart, transaction_restart_commit) \
x(0, no_btree_node) \
x(BCH_ERR_no_btree_node, no_btree_node_relock) \
x(BCH_ERR_no_btree_node, no_btree_node_upgrade) \
--
2.45.2