From 4b811835a2ffc24ed9dd20dd9b8b66c13e13daac Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 7 May 2025 20:37:22 +0200 Subject: [PATCH] 6.14-stable patches added patches: bcachefs-change-btree_insert_node-assertion-to-error.patch --- ...btree_insert_node-assertion-to-error.patch | 86 +++++++++++++++++++ queue-6.14/series | 1 + 2 files changed, 87 insertions(+) create mode 100644 queue-6.14/bcachefs-change-btree_insert_node-assertion-to-error.patch diff --git a/queue-6.14/bcachefs-change-btree_insert_node-assertion-to-error.patch b/queue-6.14/bcachefs-change-btree_insert_node-assertion-to-error.patch new file mode 100644 index 0000000000..85f233d7c6 --- /dev/null +++ b/queue-6.14/bcachefs-change-btree_insert_node-assertion-to-error.patch @@ -0,0 +1,86 @@ +From 63c3b8f616cc95bb1fcc6101c92485d41c535d7c Mon Sep 17 00:00:00 2001 +From: Kent Overstreet +Date: Sat, 29 Mar 2025 14:22:29 -0400 +Subject: bcachefs: Change btree_insert_node() assertion to error + +From: Kent Overstreet + +commit 63c3b8f616cc95bb1fcc6101c92485d41c535d7c upstream. + +Debug for https://github.com/koverstreet/bcachefs/issues/843 + +Print useful debug info and go emergency read-only. + +Signed-off-by: Kent Overstreet +Signed-off-by: Greg Kroah-Hartman +--- + fs/bcachefs/btree_update_interior.c | 17 ++++++++++++++++- + fs/bcachefs/error.c | 8 ++++++++ + fs/bcachefs/error.h | 2 ++ + 3 files changed, 26 insertions(+), 1 deletion(-) + +--- a/fs/bcachefs/btree_update_interior.c ++++ b/fs/bcachefs/btree_update_interior.c +@@ -35,6 +35,8 @@ static const char * const bch2_btree_upd + NULL + }; + ++static void bch2_btree_update_to_text(struct printbuf *, struct btree_update *); ++ + static int bch2_btree_insert_node(struct btree_update *, struct btree_trans *, + btree_path_idx_t, struct btree *, struct keylist *); + static void bch2_btree_update_add_new_node(struct btree_update *, struct btree *); +@@ -1782,11 +1784,24 @@ static int bch2_btree_insert_node(struct + int ret; + + lockdep_assert_held(&c->gc_lock); +- BUG_ON(!btree_node_intent_locked(path, b->c.level)); + BUG_ON(!b->c.level); + BUG_ON(!as || as->b); + bch2_verify_keylist_sorted(keys); + ++ if (!btree_node_intent_locked(path, b->c.level)) { ++ struct printbuf buf = PRINTBUF; ++ bch2_log_msg_start(c, &buf); ++ prt_printf(&buf, "%s(): node not locked at level %u\n", ++ __func__, b->c.level); ++ bch2_btree_update_to_text(&buf, as); ++ bch2_btree_path_to_text(&buf, trans, path_idx); ++ ++ bch2_print_string_as_lines(KERN_ERR, buf.buf); ++ printbuf_exit(&buf); ++ bch2_fs_emergency_read_only(c); ++ return -EIO; ++ } ++ + ret = bch2_btree_node_lock_write(trans, path, &b->c); + if (ret) + return ret; +--- a/fs/bcachefs/error.c ++++ b/fs/bcachefs/error.c +@@ -11,6 +11,14 @@ + + #define FSCK_ERR_RATELIMIT_NR 10 + ++void bch2_log_msg_start(struct bch_fs *c, struct printbuf *out) ++{ ++#ifdef BCACHEFS_LOG_PREFIX ++ prt_printf(out, bch2_log_msg(c, "")); ++#endif ++ printbuf_indent_add(out, 2); ++} ++ + bool bch2_inconsistent_error(struct bch_fs *c) + { + set_bit(BCH_FS_error, &c->flags); +--- a/fs/bcachefs/error.h ++++ b/fs/bcachefs/error.h +@@ -18,6 +18,8 @@ struct work_struct; + + /* Error messages: */ + ++void bch2_log_msg_start(struct bch_fs *, struct printbuf *); ++ + /* + * Inconsistency errors: The on disk data is inconsistent. If these occur during + * initial recovery, they don't indicate a bug in the running code - we walk all diff --git a/queue-6.14/series b/queue-6.14/series index c26118f545..48a773e2eb 100644 --- a/queue-6.14/series +++ b/queue-6.14/series @@ -180,3 +180,4 @@ btrfs-pass-struct-btrfs_inode-to-btrfs_iget_locked.patch btrfs-fix-the-inode-leak-in-btrfs_iget.patch drm-amd-display-add-scoped-mutexes-for-amdgpu_dm_dhc.patch drm-amd-display-fix-slab-use-after-free-in-hdcp.patch +bcachefs-change-btree_insert_node-assertion-to-error.patch -- 2.47.3