bcachefs (loop2): stripes_read... done bcachefs (loop2): snapshots_read... done bcachefs (loop2): check_allocations... ====================================================== WARNING: possible circular locking dependency detected 6.10.0-rc5-syzkaller-g5961093c073c #0 Not tainted ------------------------------------------------------ syz.2.848/8646 is trying to acquire lock: ffff0000e4800988 (&c->sb_lock){+.+.}-{3:3}, at: bch2_gc_mark_key+0x894/0xb3c fs/bcachefs/btree_gc.c:600 but task is already holding lock: ffff0000e4801a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btree fs/bcachefs/btree_gc.c:644 [inline] ffff0000e4801a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] ffff0000e4801a58 (&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:615 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:1036 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2128 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+0x130/0x23c arch/arm64/kernel/syscall.c:133 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152 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.2.848/8646: #0: ffff0000e4800278 (&c->state_lock){+.+.}-{3:3}, at: bch2_fs_start+0x50/0x53c fs/bcachefs/super.c:1006 #1: ffff0000e48268d0 (&c->gc_lock){++++}-{3:3}, at: bch2_check_allocations+0x1fc/0x80d8 fs/bcachefs/btree_gc.c:1209 #2: ffff0000e48042d8 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire+0x18/0x54 include/linux/srcu.h:115 #3: ffff0000e4801a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btree fs/bcachefs/btree_gc.c:644 [inline] #3: ffff0000e4801a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_gc_btrees fs/bcachefs/btree_gc.c:697 [inline] #3: ffff0000e4801a58 (&c->btree_root_lock){+.+.}-{3:3}, at: bch2_check_allocations+0x1c64/0x80d8 fs/bcachefs/btree_gc.c:1224 stack backtrace: CPU: 0 PID: 8646 Comm: syz.2.848 Not tainted 6.10.0-rc5-syzkaller-g5961093c073c #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/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:1036 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2128 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+0x130/0x23c arch/arm64/kernel/syscall.c:133 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152 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:40 data type btree ptr gen 0 missing in alloc btree while marking u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 2b7c77101c276712 written 8 min_key POS_MIN durability: 1 ptr: 0:40:0 gen 0, shutting down bcachefs (loop2): inconsistency detected - emergency read only at journal seq 10 bcachefs (loop2): bch2_gc_mark_key(): error fsck_errors_not_fixed bcachefs (loop2): bch2_gc_btrees(): error fsck_errors_not_fixed dev 0 has wrong free buckets: got 83, should be 84, fixing dev 0 has wrong btree buckets: got 11, should be 10, fixing dev 0 has wrong btree sectors: got 2816, should be 2560, fixing fs has wrong btree: got 2816, should be 2560, fixing fs has wrong btree: 1/1 [0]: got 2816, should be 2560, fixing done bcachefs (loop2): going read-write bcachefs (loop2): journal_replay... done bcachefs (loop2): check_alloc_info... hole in alloc btree missing in freespace btree device 0 buckets 40-41, shutting down bcachefs (loop2): bch2_check_alloc_info(): error fsck_errors_not_fixed bcachefs (loop2): bch2_fs_recovery(): error fsck_errors_not_fixed bcachefs (loop2): bch2_fs_start(): error starting filesystem fsck_errors_not_fixed bcachefs (loop2): shutting down bcachefs (loop2): shutdown complete