====================================================== WARNING: possible circular locking dependency detected 5.15.189-syzkaller #0 Not tainted ------------------------------------------------------ syz.8.756/7830 is trying to acquire lock: ffff88805f0a5e60 (&type->i_mutex_dir_key#9){++++}-{3:3}, at: inode_lock_shared include/linux/fs.h:797 [inline] ffff88805f0a5e60 (&type->i_mutex_dir_key#9){++++}-{3:3}, at: lookup_slow+0x46/0x70 fs/namei.c:1679 but task is already holding lock: ffff8880296080e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x186/0xa60 fs/btrfs/volumes.c:603 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x1eb/0x2390 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743 insert_dev_extents fs/btrfs/block-group.c:2399 [inline] btrfs_create_pending_block_groups+0x4a6/0xe50 fs/btrfs/block-group.c:2449 __btrfs_end_transaction+0x154/0x650 fs/btrfs/transaction.c:1016 btrfs_inc_block_group_ro+0x59d/0x600 fs/btrfs/block-group.c:2664 btrfs_relocate_block_group+0x418/0xd00 fs/btrfs/relocation.c:4041 btrfs_relocate_chunk+0xaa/0x290 fs/btrfs/volumes.c:3338 __btrfs_balance+0x1641/0x2250 fs/btrfs/volumes.c:4079 btrfs_balance+0xd89/0x1520 fs/btrfs/volumes.c:4469 btrfs_ioctl_balance+0x674/0x810 fs/btrfs/ioctl.c:4152 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #1 (sb_internal#2){.+.+}-{0:0}: percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1811 [inline] sb_start_intwrite include/linux/fs.h:1928 [inline] start_transaction+0x5bc/0x1130 fs/btrfs/transaction.c:680 btrfs_dirty_inode+0xc5/0x1c0 fs/btrfs/inode.c:6451 inode_update_time fs/inode.c:1893 [inline] touch_atime+0x2f6/0x620 fs/inode.c:1966 file_accessed include/linux/fs.h:2521 [inline] iterate_dir+0x482/0x560 fs/readdir.c:70 __do_sys_getdents fs/readdir.c:286 [inline] __se_sys_getdents+0xe5/0x250 fs/readdir.c:271 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #0 (&type->i_mutex_dir_key#9){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3053 [inline] check_prevs_add kernel/locking/lockdep.c:3172 [inline] validate_chain kernel/locking/lockdep.c:3788 [inline] __lock_acquire+0x2c33/0x7c60 kernel/locking/lockdep.c:5012 lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623 down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x46/0x70 fs/namei.c:1679 walk_component+0x319/0x460 fs/namei.c:1976 lookup_last fs/namei.c:2431 [inline] path_lookupat+0x169/0x440 fs/namei.c:2455 filename_lookup+0x1e2/0x4f0 fs/namei.c:2484 kern_path+0x37/0x190 fs/namei.c:2582 lookup_bdev+0xbd/0x270 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x6db/0xa60 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x52/0x80 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x104/0x220 fs/btrfs/super.c:2450 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#9 --> sb_internal#2 --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(sb_internal#2); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#9); *** DEADLOCK *** 2 locks held by syz.8.756/7830: #0: ffffffff8c605688 (uuid_mutex){+.+.}-{3:3}, at: btrfs_forget_devices+0x1a/0x80 fs/btrfs/volumes.c:1430 #1: ffff8880296080e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x186/0xa60 fs/btrfs/volumes.c:603 stack backtrace: CPU: 1 PID: 7830 Comm: syz.8.756 Not tainted 5.15.189-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 Call Trace: dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106 check_noncircular+0x274/0x310 kernel/locking/lockdep.c:2133 check_prev_add kernel/locking/lockdep.c:3053 [inline] check_prevs_add kernel/locking/lockdep.c:3172 [inline] validate_chain kernel/locking/lockdep.c:3788 [inline] __lock_acquire+0x2c33/0x7c60 kernel/locking/lockdep.c:5012 lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623 down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x46/0x70 fs/namei.c:1679 walk_component+0x319/0x460 fs/namei.c:1976 lookup_last fs/namei.c:2431 [inline] path_lookupat+0x169/0x440 fs/namei.c:2455 filename_lookup+0x1e2/0x4f0 fs/namei.c:2484 kern_path+0x37/0x190 fs/namei.c:2582 lookup_bdev+0xbd/0x270 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x6db/0xa60 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x52/0x80 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x104/0x220 fs/btrfs/super.c:2450 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 RIP: 0033:0x7f133139dbe9 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:00007f132f5e4038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f13315c5090 RCX: 00007f133139dbe9 RDX: 0000200000000240 RSI: 0000000050009405 RDI: 0000000000000005 RBP: 00007f1331420e19 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f13315c5128 R14: 00007f13315c5090 R15: 00007fffef9c8fd8 netlink: 4 bytes leftover after parsing attributes in process `syz.8.756'.