====================================================== WARNING: possible circular locking dependency detected 6.16.0-rc3-syzkaller-00121-gf02769e7f272 #0 Not tainted ------------------------------------------------------ syz.6.377/9209 is trying to acquire lock: ffff888049c19638 (&type->i_mutex_dir_key#8){++++}-{4:4}, at: inode_lock_shared include/linux/fs.h:884 [inline] ffff888049c19638 (&type->i_mutex_dir_key#8){++++}-{4:4}, at: lookup_slow+0x46/0x70 fs/namei.c:1833 but task is already holding lock: ffff8880564f98d8 (&fs_devs->device_list_mutex){+.+.}-{4:4}, at: device_list_add+0x468/0x1b60 fs/btrfs/volumes.c:837 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&fs_devs->device_list_mutex){+.+.}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871 __mutex_lock_common kernel/locking/mutex.c:602 [inline] __mutex_lock+0x182/0xe80 kernel/locking/mutex.c:747 insert_dev_extents fs/btrfs/block-group.c:2739 [inline] btrfs_create_pending_block_groups+0x5e2/0x1360 fs/btrfs/block-group.c:2790 __btrfs_end_transaction+0x140/0x640 fs/btrfs/transaction.c:1071 flush_space+0x315/0xcd0 fs/btrfs/space-info.c:865 do_async_reclaim_data_space+0x11c/0x520 fs/btrfs/space-info.c:1394 btrfs_async_reclaim_data_space+0x41/0x90 fs/btrfs/space-info.c:1458 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xade/0x17b0 kernel/workqueue.c:3321 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3402 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #2 (btrfs_trans_num_extwriters){++++}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871 join_transaction+0x1a4/0xd70 fs/btrfs/transaction.c:321 start_transaction+0x6b6/0x1620 fs/btrfs/transaction.c:705 btrfs_rebuild_free_space_tree+0xb1/0x4e0 fs/btrfs/free-space-tree.c:1341 btrfs_start_pre_rw_mount+0xd76/0x1180 fs/btrfs/disk-io.c:3078 open_ctree+0x2078/0x2800 fs/btrfs/disk-io.c:3618 btrfs_fill_super+0x19d/0x2e0 fs/btrfs/super.c:968 btrfs_get_tree_super fs/btrfs/super.c:1893 [inline] btrfs_get_tree+0x107c/0x1630 fs/btrfs/super.c:2088 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 fc_mount+0x1c/0xb0 fs/namespace.c:1290 btrfs_get_tree_subvol fs/btrfs/super.c:2046 [inline] btrfs_get_tree+0x67d/0x1630 fs/btrfs/super.c:2089 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (btrfs_trans_num_writers){++++}-{0:0}: reacquire_held_locks+0x127/0x1d0 kernel/locking/lockdep.c:5388 __lock_release kernel/locking/lockdep.c:5577 [inline] lock_release+0x1b4/0x3e0 kernel/locking/lockdep.c:5892 percpu_up_read include/linux/percpu-rwsem.h:112 [inline] __sb_end_write include/linux/fs.h:1790 [inline] sb_end_intwrite+0x26/0x1c0 include/linux/fs.h:1907 __btrfs_end_transaction+0x248/0x640 fs/btrfs/transaction.c:1076 btrfs_fileattr_set+0x7df/0xbd0 fs/btrfs/ioctl.c:400 vfs_fileattr_set+0x850/0xb00 fs/ioctl.c:696 do_vfs_ioctl+0x1602/0x1990 fs/ioctl.c:-1 __do_sys_ioctl fs/ioctl.c:905 [inline] __se_sys_ioctl+0x82/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&type->i_mutex_dir_key#8){++++}-{4:4}: check_prev_add kernel/locking/lockdep.c:3168 [inline] check_prevs_add kernel/locking/lockdep.c:3287 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3911 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5240 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871 down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524 inode_lock_shared include/linux/fs.h:884 [inline] lookup_slow+0x46/0x70 fs/namei.c:1833 walk_component fs/namei.c:2138 [inline] link_path_walk+0x935/0xea0 fs/namei.c:2506 path_lookupat+0x97/0x430 fs/namei.c:2662 filename_lookup+0x212/0x570 fs/namei.c:2692 kern_path+0x35/0x50 fs/namei.c:2825 is_same_device fs/btrfs/volumes.c:757 [inline] device_list_add+0xd74/0x1b60 fs/btrfs/volumes.c:892 btrfs_scan_one_device+0x3fe/0x5b0 fs/btrfs/volumes.c:1485 btrfs_get_tree_super fs/btrfs/super.c:1842 [inline] btrfs_get_tree+0x321/0x1630 fs/btrfs/super.c:2088 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 fc_mount+0x1c/0xb0 fs/namespace.c:1290 btrfs_get_tree_subvol fs/btrfs/super.c:2046 [inline] btrfs_get_tree+0x67d/0x1630 fs/btrfs/super.c:2089 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#8 --> btrfs_trans_num_extwriters --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(btrfs_trans_num_extwriters); lock(&fs_devs->device_list_mutex); rlock(&type->i_mutex_dir_key#8); *** DEADLOCK *** 2 locks held by syz.6.377/9209: #0: ffffffff8e6e6fc8 (uuid_mutex){+.+.}-{4:4}, at: btrfs_get_tree_super fs/btrfs/super.c:1836 [inline] #0: ffffffff8e6e6fc8 (uuid_mutex){+.+.}-{4:4}, at: btrfs_get_tree+0x2f0/0x1630 fs/btrfs/super.c:2088 #1: ffff8880564f98d8 (&fs_devs->device_list_mutex){+.+.}-{4:4}, at: device_list_add+0x468/0x1b60 fs/btrfs/volumes.c:837 stack backtrace: CPU: 1 UID: 0 PID: 9209 Comm: syz.6.377 Not tainted 6.16.0-rc3-syzkaller-00121-gf02769e7f272 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2046 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2178 check_prev_add kernel/locking/lockdep.c:3168 [inline] check_prevs_add kernel/locking/lockdep.c:3287 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3911 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5240 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871 down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524 inode_lock_shared include/linux/fs.h:884 [inline] lookup_slow+0x46/0x70 fs/namei.c:1833 walk_component fs/namei.c:2138 [inline] link_path_walk+0x935/0xea0 fs/namei.c:2506 path_lookupat+0x97/0x430 fs/namei.c:2662 filename_lookup+0x212/0x570 fs/namei.c:2692 kern_path+0x35/0x50 fs/namei.c:2825 is_same_device fs/btrfs/volumes.c:757 [inline] device_list_add+0xd74/0x1b60 fs/btrfs/volumes.c:892 btrfs_scan_one_device+0x3fe/0x5b0 fs/btrfs/volumes.c:1485 btrfs_get_tree_super fs/btrfs/super.c:1842 [inline] btrfs_get_tree+0x321/0x1630 fs/btrfs/super.c:2088 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 fc_mount+0x1c/0xb0 fs/namespace.c:1290 btrfs_get_tree_subvol fs/btrfs/super.c:2046 [inline] btrfs_get_tree+0x67d/0x1630 fs/btrfs/super.c:2089 vfs_get_tree+0x8f/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f2a3ed8e929 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007f2a3fce1038 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f2a3efb5fa0 RCX: 00007f2a3ed8e929 RDX: 0000200000000280 RSI: 0000200000000180 RDI: 0000200000000100 RBP: 00007f2a3ee10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f2a3efb5fa0 R15: 00007ffdf06e9478 BTRFS info: devid 1 device path /dev/loop6 changed to /dev/loop6 scanned by syz.6.377 (9209)