@@ -35,6 +35,8 @@ static const char * const bch2_btree_update_modes[] = {
3535 NULL
3636};
3737
38+ static void bch2_btree_update_to_text (struct printbuf * , struct btree_update * );
39+
3840static int bch2_btree_insert_node (struct btree_update * , struct btree_trans * ,
3941 btree_path_idx_t , struct btree * , struct keylist * );
4042static void bch2_btree_update_add_new_node (struct btree_update * , struct btree * );
@@ -1777,11 +1779,24 @@ static int bch2_btree_insert_node(struct btree_update *as, struct btree_trans *t
17771779 int ret ;
17781780
17791781 lockdep_assert_held (& c -> gc_lock );
1780- BUG_ON (!btree_node_intent_locked (path , b -> c .level ));
17811782 BUG_ON (!b -> c .level );
17821783 BUG_ON (!as || as -> b );
17831784 bch2_verify_keylist_sorted (keys );
17841785
1786+ if (!btree_node_intent_locked (path , b -> c .level )) {
1787+ struct printbuf buf = PRINTBUF ;
1788+ bch2_log_msg_start (c , & buf );
1789+ prt_printf (& buf , "%s(): node not locked at level %u\n" ,
1790+ __func__ , b -> c .level );
1791+ bch2_btree_update_to_text (& buf , as );
1792+ bch2_btree_path_to_text (& buf , trans , path_idx );
1793+
1794+ bch2_print_string_as_lines (KERN_ERR , buf .buf );
1795+ printbuf_exit (& buf );
1796+ bch2_fs_emergency_read_only (c );
1797+ return - EIO ;
1798+ }
1799+
17851800 ret = bch2_btree_node_lock_write (trans , path , & b -> c );
17861801 if (ret )
17871802 return ret ;
0 commit comments