------------[ cut here ]------------
WARNING: CPU: 1 PID: 5880 at fs/bcachefs/btree_iter.c:3194 __bch2_trans_kmalloc+0x50f/0x9d0
Modules linked in:
CPU: 1 UID: 0 PID: 5880 Comm: kworker/1:3 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: bcachefs_write_ref bch2_do_discards_work
RIP: 0010:__bch2_trans_kmalloc+0x50f/0x9d0
Code: 00 28 00 00 e8 d2 5b 35 00 48 c7 c0 75 f7 ff ff 48 83 c4 48 5b 41 5c 41 5d 41 5e 41 5f 5d e9 c8 3e 53 07 cc e8 d2 8e 96 fd 90 <0f> 0b 90 e9 d3 fb ff ff e8 c4 8e 96 fd 90 0f 0b 90 e9 dc fd ff ff
RSP: 0018:ffffc90003a4ea70 EFLAGS: 00010293
RAX: ffffffff84291c5e RBX: ffff888109f78000 RCX: ffff88810c1e0000
RDX: 0000000000000000 RSI: 0000000000020000 RDI: 0000000000010000
RBP: 0000000000020000 R08: ffffc90003a4ee70 R09: 0000000000000001
R10: ffffc90003a4ed80 R11: fffff52000749d7d R12: dffffc0000000000
R13: ffff888109f78030 R14: 1ffff110213ef000 R15: 0000000000000011
FS:  0000000000000000(0000) GS:ffff8881a3c1b000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b31123ffc CR3: 0000000118b98000 CR4: 00000000000006f0
Call Trace:
 <TASK>
 bch2_alloc_sectors_start_trans+0x1d59/0x1e80
 bch2_btree_reserve_get+0x641/0x1810
 bch2_btree_update_start+0x18ff/0x1de0
 bch2_btree_split_leaf+0x14b/0x8e0
 bch2_trans_commit_error+0x1b7/0x1130
 __bch2_trans_commit+0x1bb5/0x8870
 bch2_discard_one_bucket+0xa32/0x11a0
 bch2_do_discards_work+0x3b3/0x9c0
 process_scheduled_works+0xae1/0x17b0
 worker_thread+0x8a0/0xda0
 kthread+0x711/0x8a0
 ret_from_fork+0x3fc/0x770
 ret_from_fork_asm+0x1a/0x30
 </TASK>
