bucket 0:22 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:22 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:23 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:23 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:24 gen 0 has wrong data_type: got free, should be journal, fixing
bucket 0:24 gen 0 data type journal has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:26 gen 0 has wrong data_type: got free, should be btree, fixing
bucket 0:26 gen 0 data type btree has wrong dirty_sectors: got 0, should be 32, fixing
bucket 0:27 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:28 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:29 gen 0 has wrong data_type: got free, should be btree, fixing
bucket 0:29 gen 0 data type btree has wrong dirty_sectors: got 0, should be 32, fixing
bucket 0:31 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:32 gen 0 has wrong data_type: got sb, should be btree, fixing
bucket 0:32 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:35 gen 0 has wrong data_type: got free, should be btree, fixing
bucket 0:35 gen 0 data type btree has wrong dirty_sectors: got 0, should be 32, fixing
bucket 0:37 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:38 gen 0 has wrong data_type: got free, should be btree, fixing
bucket 0:38 gen 0 data type btree has wrong dirty_sectors: got 0, should be 32, fixing
bucket 0:41 gen 0 has wrong data_type: got free, should be btree, fixing
bucket 0:41 gen 0 data type btree has wrong dirty_sectors: got 0, should be 32, fixing
bucket 0:42 gen 0 data type btree has wrong dirty_sectors: got 256, should be 32, fixing
bucket 0:120 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:120 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:121 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:121 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:122 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:122 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:123 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:123 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:124 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:124 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:125 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:125 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:126 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:126 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
bucket 0:127 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:127 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing
 done
bcachefs (loop0): going read-write
bcachefs (loop0): journal_replay... done
bcachefs (loop0): check_alloc_info... done
bcachefs (loop0): check_lrus... done
bcachefs (loop0): check_btree_backpointers... done
bcachefs (loop0): check_backpointers_to_extents... done
bcachefs (loop0): check_extents_to_backpointers...
bcachefs (loop0): scanning for missing backpointers in 7/128 buckets
bcachefs (loop0): journal_entry_open(): fatal error cannot start: journal seq overflow
============================================
WARNING: possible recursive locking detected
6.13.0-syzkaller-02526-gc4b9570cfb63 #0 Not tainted
--------------------------------------------
syz.0.0/5321 is trying to acquire lock:
ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: bch2_journal_halt+0x2f/0x110 fs/bcachefs/journal.c:315

but task is already holding lock:
ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: __journal_res_get+0x497/0x26b0 fs/bcachefs/journal.c:533

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&j->lock);
  lock(&j->lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

4 locks held by syz.0.0/5321:
 #0: ffff888052d80278 (&c->state_lock){+.+.}-{4:4}, at: bch2_fs_start+0x45/0x610 fs/bcachefs/super.c:999
 #1: ffff888052d84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:164 [inline]
 #1: ffff888052d84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:256 [inline]
 #1: ffff888052d84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7e4/0xd30 fs/bcachefs/btree_iter.c:3378
 #2: ffff888043ce8140 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:198 [inline]
 #2: ffff888043ce8140 (bcachefs_btree){+.+.}-{0:0}, at: bch2_trans_begin+0x9ca/0x1d90 fs/bcachefs/btree_iter.c:3275
 #3: ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #3: ffff888052dca980 (&j->lock){+.+.}-{3:3}, at: __journal_res_get+0x497/0x26b0 fs/bcachefs/journal.c:533

stack backtrace:
CPU: 0 UID: 0 PID: 5321 Comm: syz.0.0 Not tainted 6.13.0-syzkaller-02526-gc4b9570cfb63 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_deadlock_bug+0x483/0x620 kernel/locking/lockdep.c:3039
 check_deadlock kernel/locking/lockdep.c:3091 [inline]
 validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3893
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5228
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:351 [inline]
 bch2_journal_halt+0x2f/0x110 fs/bcachefs/journal.c:315
 bch2_fs_emergency_read_only+0x50/0xc0 fs/bcachefs/super.c:407
 bch2_fatal_error+0x15/0x40 fs/bcachefs/error.c:49
 journal_entry_open fs/bcachefs/journal.c:385 [inline]
 __journal_res_get+0xbef/0x26b0 fs/bcachefs/journal.c:557
 bch2_journal_res_get_slowpath+0xe6/0x710 fs/bcachefs/journal.c:619
 bch2_journal_res_get fs/bcachefs/journal.h:383 [inline]
 bch2_trans_journal_res_get fs/bcachefs/btree_trans_commit.c:350 [inline]
 bch2_trans_commit_write_locked fs/bcachefs/btree_trans_commit.c:652 [inline]
 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:866 [inline]
 __bch2_trans_commit+0x353c/0x97a0 fs/bcachefs/btree_trans_commit.c:1066
 bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline]
 bch2_check_extents_to_backpointers_pass fs/bcachefs/backpointers.c:797 [inline]
 bch2_check_extents_to_backpointers+0x5ffb/0x7360 fs/bcachefs/backpointers.c:1130
 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226
 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:291
 bch2_fs_recovery+0x265a/0x3de0 fs/bcachefs/recovery.c:937
 bch2_fs_start+0x37c/0x610 fs/bcachefs/super.c:1030
 bch2_fs_get_tree+0xd8d/0x1740 fs/bcachefs/fs.c:2203
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3560
 do_mount fs/namespace.c:3900 [inline]
 __do_sys_mount fs/namespace.c:4111 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4088
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f608f7874ca
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f60905c8e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f60905c8ef0 RCX: 00007f608f7874ca
RDX: 00000000200000c0 RSI: 0000000020000180 RDI: 00007f60905c8eb0
RBP: 00000000200000c0 R08: 00007f60905c8ef0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000020000180
R13: 00007f60905c8eb0 R14: 000000000000599b R15: 0000000020000000
 </TASK>