bcachefs (loop1): stripes_read... done bcachefs (loop1): snapshots_read... done bcachefs (loop1): check_allocations... ====================================================== WARNING: possible circular locking dependency detected 6.10.0-rc6-syzkaller-g8e2f4becf4fa #0 Not tainted ------------------------------------------------------ syz.1.236/7340 is trying to acquire lock: ffff0000e6380988 (&c->sb_lock){+.+.}-{3:3}, at: bch2_gc_mark_key+0x894/0xb3c fs/bcachefs/btree_gc.c:600 but task is already holding lock: ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btree fs/bcachefs/btree_gc.c:644 [inline] ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_check_allocations+0x1c64/0x80d8 fs/bcachefs/btree_gc.c:1224 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&c->btree_root_lock){+.+.}-{3:3}: __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608 __mutex_lock kernel/locking/mutex.c:752 [inline] mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804 bch2_btree_roots_to_journal_entries+0xb8/0x4c0 fs/bcachefs/btree_update_interior.c:2633 bch2_fs_mark_clean+0x288/0x5e8 fs/bcachefs/sb-clean.c:376 bch2_fs_read_only+0xd88/0xf0c fs/bcachefs/super.c:381 __bch2_fs_stop+0x100/0x510 fs/bcachefs/super.c:614 bch2_put_super+0x40/0x50 fs/bcachefs/fs.c:1811 generic_shutdown_super+0x128/0x2b8 fs/super.c:642 bch2_kill_sb+0x40/0x58 fs/bcachefs/fs.c:2044 deactivate_locked_super+0xc4/0x12c fs/super.c:473 deactivate_super+0xe0/0x100 fs/super.c:506 cleanup_mnt+0x34c/0x3dc fs/namespace.c:1267 __cleanup_mnt+0x20/0x30 fs/namespace.c:1274 task_work_run+0x230/0x2e0 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] do_notify_resume+0x178/0x1f4 arch/arm64/kernel/entry-common.c:151 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xac/0x168 arch/arm64/kernel/entry-common.c:713 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 -> #0 (&c->sb_lock){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3134 [inline] check_prevs_add kernel/locking/lockdep.c:3253 [inline] validate_chain kernel/locking/lockdep.c:3869 [inline] __lock_acquire+0x3384/0x763c kernel/locking/lockdep.c:5137 lock_acquire+0x240/0x728 kernel/locking/lockdep.c:5754 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608 __mutex_lock kernel/locking/mutex.c:752 [inline] mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804 bch2_gc_mark_key+0x894/0xb3c fs/bcachefs/btree_gc.c:600 bch2_gc_btree fs/bcachefs/btree_gc.c:648 [inline] bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] bch2_check_allocations+0x2680/0x80d8 fs/bcachefs/btree_gc.c:1224 bch2_run_recovery_pass+0xe4/0x1d4 fs/bcachefs/recovery_passes.c:182 bch2_run_recovery_passes+0x258/0x6e0 fs/bcachefs/recovery_passes.c:225 bch2_fs_recovery+0x31f0/0x5488 fs/bcachefs/recovery.c:813 bch2_fs_start+0x30c/0x53c fs/bcachefs/super.c:1035 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2132 bch2_mount+0x4fc/0xe68 fs/bcachefs/fs.c:1926 legacy_get_tree+0xd4/0x16c fs/fs_context.c:662 vfs_get_tree+0x90/0x288 fs/super.c:1780 do_new_mount+0x278/0x900 fs/namespace.c:3352 path_mount+0x590/0xe04 fs/namespace.c:3679 do_mount fs/namespace.c:3692 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount fs/namespace.c:3875 [inline] __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3875 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48 el0_svc_common+0x1e0/0x23c arch/arm64/kernel/syscall.c:131 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&c->btree_root_lock); lock(&c->sb_lock); lock(&c->btree_root_lock); lock(&c->sb_lock); *** DEADLOCK *** 4 locks held by syz.1.236/7340: #0: ffff0000e6380278 (&c->state_lock){+.+.}-{3:3}, at: bch2_fs_start+0x50/0x53c fs/bcachefs/super.c:1005 #1: ffff0000e63a6750 (&c->gc_lock){++++}-{3:3}, at: bch2_check_allocations+0x1fc/0x80d8 fs/bcachefs/btree_gc.c:1209 #2: ffff0000e63842d8 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire+0x18/0x54 include/linux/srcu.h:115 #3: ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btree fs/bcachefs/btree_gc.c:644 [inline] #3: ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] #3: ffff0000e6381a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_check_allocations+0x1c64/0x80d8 fs/bcachefs/btree_gc.c:1224 stack backtrace: CPU: 0 PID: 7340 Comm: syz.1.236 Not tainted 6.10.0-rc6-syzkaller-g8e2f4becf4fa #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call trace: dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:317 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:324 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:114 dump_stack+0x1c/0x28 lib/dump_stack.c:123 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2060 check_noncircular+0x310/0x404 kernel/locking/lockdep.c:2187 check_prev_add kernel/locking/lockdep.c:3134 [inline] check_prevs_add kernel/locking/lockdep.c:3253 [inline] validate_chain kernel/locking/lockdep.c:3869 [inline] __lock_acquire+0x3384/0x763c kernel/locking/lockdep.c:5137 lock_acquire+0x240/0x728 kernel/locking/lockdep.c:5754 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608 __mutex_lock kernel/locking/mutex.c:752 [inline] mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804 bch2_gc_mark_key+0x894/0xb3c fs/bcachefs/btree_gc.c:600 bch2_gc_btree fs/bcachefs/btree_gc.c:648 [inline] bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] bch2_check_allocations+0x2680/0x80d8 fs/bcachefs/btree_gc.c:1224 bch2_run_recovery_pass+0xe4/0x1d4 fs/bcachefs/recovery_passes.c:182 bch2_run_recovery_passes+0x258/0x6e0 fs/bcachefs/recovery_passes.c:225 bch2_fs_recovery+0x31f0/0x5488 fs/bcachefs/recovery.c:813 bch2_fs_start+0x30c/0x53c fs/bcachefs/super.c:1035 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2132 bch2_mount+0x4fc/0xe68 fs/bcachefs/fs.c:1926 legacy_get_tree+0xd4/0x16c fs/fs_context.c:662 vfs_get_tree+0x90/0x288 fs/super.c:1780 do_new_mount+0x278/0x900 fs/namespace.c:3352 path_mount+0x590/0xe04 fs/namespace.c:3679 do_mount fs/namespace.c:3692 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount fs/namespace.c:3875 [inline] __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3875 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48 el0_svc_common+0x1e0/0x23c arch/arm64/kernel/syscall.c:131 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 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 done bcachefs (loop1): going read-write bcachefs (loop1): journal_replay... done bcachefs (loop1): check_alloc_info... done bcachefs (loop1): check_lrus... done bcachefs (loop1): check_btree_backpointers... done bcachefs (loop1): check_backpointers_to_extents... done bcachefs (loop1): check_extents_to_backpointers... missing backpointer for btree=inodes l=1 u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq efdd7a26d7396dd5 written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0 got: u64s 5 type deleted 0:9961472:0 len 0 ver 0 want: u64s 9 type backpointer 0:9961472:0 len 0 ver 0: bucket=0:38:0 btree=inodes l=1 offset=0:0 len=256 pos=SPOS_MAX, shutting down bcachefs (loop1): inconsistency detected - emergency read only at journal seq 12 bcachefs (loop1): bch2_check_extents_to_backpointers(): error fsck_errors_not_fixed bcachefs (loop1): bch2_fs_recovery(): error fsck_errors_not_fixed bcachefs (loop1): bch2_fs_start(): error starting filesystem fsck_errors_not_fixed bcachefs (loop1): shutting down bcachefs (loop1): going read-only bcachefs (loop1): finished waiting for writes to stop bcachefs (loop1): flushing journal and stopping allocators, journal seq 12 bcachefs (loop1): flushing journal and stopping allocators complete, journal seq 12 bcachefs (loop1): unshutdown complete, journal seq 12 bcachefs (loop1): done going read-only, filesystem not clean bcachefs (loop1): shutdown complete