====================================================== WARNING: possible circular locking dependency detected 6.12.0-next-20241128-syzkaller #0 Not tainted ------------------------------------------------------ btrfs-cleaner/7238 is trying to acquire lock: ffff88807c3c2e18 (&delayed_node->mutex){+.+.}-{4:4}, at: __btrfs_release_delayed_node+0xa5/0xaf0 fs/btrfs/delayed-inode.c:268 but task is already holding lock: ffff88805d870e18 (btrfs-tree-00){++++}-{4:4}, at: btrfs_tree_read_lock_nested+0x2f/0x250 fs/btrfs/locking.c:146 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (btrfs-tree-00){++++}-{4:4}: reacquire_held_locks+0x3eb/0x690 kernel/locking/lockdep.c:5374 __lock_release kernel/locking/lockdep.c:5563 [inline] lock_release+0x396/0xa30 kernel/locking/lockdep.c:5870 up_read+0x16/0x20 kernel/locking/rwsem.c:1619 btrfs_tree_unlock_rw fs/btrfs/locking.h:203 [inline] btrfs_search_slot+0xd50/0x3150 fs/btrfs/ctree.c:2179 btrfs_lookup_inode+0xdc/0x480 fs/btrfs/inode-item.c:411 __btrfs_update_delayed_inode+0x1e7/0xb90 fs/btrfs/delayed-inode.c:1030 btrfs_update_delayed_inode fs/btrfs/delayed-inode.c:1114 [inline] __btrfs_commit_inode_delayed_items+0x2318/0x24a0 fs/btrfs/delayed-inode.c:1137 __btrfs_run_delayed_items+0x213/0x490 fs/btrfs/delayed-inode.c:1171 flush_space+0x24a/0xcf0 fs/btrfs/space-info.c:775 btrfs_async_reclaim_metadata_space+0x113/0x350 fs/btrfs/space-info.c:1105 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3310 worker_thread+0x870/0xd30 kernel/workqueue.c:3391 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #0 (&delayed_node->mutex){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 __btrfs_release_delayed_node+0xa5/0xaf0 fs/btrfs/delayed-inode.c:268 btrfs_evict_inode+0x752/0x1080 fs/btrfs/inode.c:5374 evict+0x4e8/0x9a0 fs/inode.c:796 btrfs_read_locked_inode+0x1027/0x1570 fs/btrfs/inode.c:3996 btrfs_iget+0x1ca/0x2b0 fs/btrfs/inode.c:5612 btrfs_run_defrag_inode fs/btrfs/defrag.c:246 [inline] btrfs_run_defrag_inodes+0x6bb/0xe40 fs/btrfs/defrag.c:318 cleaner_kthread+0x28c/0x3d0 fs/btrfs/disk-io.c:1525 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(btrfs-tree-00); lock(&delayed_node->mutex); lock(btrfs-tree-00); lock(&delayed_node->mutex); *** DEADLOCK *** 1 lock held by btrfs-cleaner/7238: #0: ffff88805d870e18 (btrfs-tree-00){++++}-{4:4}, at: btrfs_tree_read_lock_nested+0x2f/0x250 fs/btrfs/locking.c:146 stack backtrace: CPU: 1 UID: 0 PID: 7238 Comm: btrfs-cleaner Not tainted 6.12.0-next-20241128-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 __btrfs_release_delayed_node+0xa5/0xaf0 fs/btrfs/delayed-inode.c:268 btrfs_evict_inode+0x752/0x1080 fs/btrfs/inode.c:5374 evict+0x4e8/0x9a0 fs/inode.c:796 btrfs_read_locked_inode+0x1027/0x1570 fs/btrfs/inode.c:3996 btrfs_iget+0x1ca/0x2b0 fs/btrfs/inode.c:5612 btrfs_run_defrag_inode fs/btrfs/defrag.c:246 [inline] btrfs_run_defrag_inodes+0x6bb/0xe40 fs/btrfs/defrag.c:318 cleaner_kthread+0x28c/0x3d0 fs/btrfs/disk-io.c:1525 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244