BTRFS info (device loop0): using free space tree BTRFS info (device loop0): has skinny extents BTRFS info (device loop0): enabling ssd optimizations ====================================================== WARNING: possible circular locking dependency detected 5.15.180-syzkaller #0 Not tainted ------------------------------------------------------ syz.0.16/4856 is trying to acquire lock: ffff0000e18e0610 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: inode_lock_shared include/linux/fs.h:797 [inline] ffff0000e18e0610 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: lookup_slow+0x4c/0x80 fs/namei.c:1679 but task is already holding lock: ffff0000ebb628e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x144/0x908 fs/btrfs/volumes.c:603 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x194/0x1edc kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xac/0x11c kernel/locking/mutex.c:743 write_all_supers+0x1080/0x35a8 fs/btrfs/disk-io.c:4159 btrfs_sync_log+0x17c8/0x1f48 fs/btrfs/tree-log.c:3327 btrfs_sync_file+0x990/0xe7c fs/btrfs/file.c:2371 vfs_fsync_range fs/sync.c:188 [inline] vfs_fsync fs/sync.c:202 [inline] do_fsync fs/sync.c:212 [inline] __do_sys_fdatasync fs/sync.c:225 [inline] __se_sys_fdatasync fs/sync.c:223 [inline] __arm64_sys_fdatasync+0xac/0x104 fs/sync.c:223 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #2 (&fs_info->tree_log_mutex){+.+.}-{3:3}: __mutex_lock_common+0x194/0x1edc kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xac/0x11c kernel/locking/mutex.c:743 btrfs_sync_log+0x1714/0x1f48 fs/btrfs/tree-log.c:3308 btrfs_sync_file+0x990/0xe7c fs/btrfs/file.c:2371 vfs_fsync_range fs/sync.c:188 [inline] vfs_fsync fs/sync.c:202 [inline] do_fsync fs/sync.c:212 [inline] __do_sys_fdatasync fs/sync.c:225 [inline] __se_sys_fdatasync fs/sync.c:223 [inline] __arm64_sys_fdatasync+0xac/0x104 fs/sync.c:223 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #1 (sb_internal#2){.+.+}-{0:0}: __lock_release kernel/locking/lockdep.c:5339 [inline] lock_release+0x2e8/0x8e8 kernel/locking/lockdep.c:5643 up_write+0x98/0x644 kernel/locking/rwsem.c:1603 btrfs_inode_unlock+0x40/0x7c fs/btrfs/inode.c:140 btrfs_sync_file+0x8d8/0xe7c fs/btrfs/file.c:2362 vfs_fsync_range fs/sync.c:188 [inline] vfs_fsync fs/sync.c:202 [inline] do_fsync fs/sync.c:212 [inline] __do_sys_fdatasync fs/sync.c:225 [inline] __se_sys_fdatasync fs/sync.c:223 [inline] __arm64_sys_fdatasync+0xac/0x104 fs/sync.c:223 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #0 (&type->i_mutex_dir_key#8){++++}-{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+0x2928/0x651c kernel/locking/lockdep.c:5012 lock_acquire+0x1f4/0x620 kernel/locking/lockdep.c:5623 down_read+0xc0/0x390 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x4c/0x80 fs/namei.c:1679 walk_component+0x2b0/0x3a8 fs/namei.c:1976 link_path_walk+0x590/0xb8c fs/namei.c:-1 path_lookupat+0x90/0x3d0 fs/namei.c:2454 filename_lookup+0x180/0x414 fs/namei.c:2484 kern_path+0x4c/0x190 fs/namei.c:2582 lookup_bdev+0xbc/0x244 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x614/0x908 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x5c/0x98 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x130/0x248 fs/btrfs/super.c:2451 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:860 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#8 --> &fs_info->tree_log_mutex --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(&fs_info->tree_log_mutex); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#8); *** DEADLOCK *** 2 locks held by syz.0.16/4856: #0: ffff8000147f9b68 (uuid_mutex){+.+.}-{3:3}, at: btrfs_forget_devices+0x28/0x98 fs/btrfs/volumes.c:1430 #1: ffff0000ebb628e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x144/0x908 fs/btrfs/volumes.c:603 stack backtrace: CPU: 0 PID: 4856 Comm: syz.0.16 Not tainted 5.15.180-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call trace: dump_backtrace+0x0/0x43c arch/arm64/kernel/stacktrace.c:152 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216 __dump_stack+0x30/0x40 lib/dump_stack.c:88 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106 dump_stack+0x1c/0x5c lib/dump_stack.c:113 print_circular_bug+0x148/0x1b0 kernel/locking/lockdep.c:2011 check_noncircular+0x240/0x2d4 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+0x2928/0x651c kernel/locking/lockdep.c:5012 lock_acquire+0x1f4/0x620 kernel/locking/lockdep.c:5623 down_read+0xc0/0x390 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x4c/0x80 fs/namei.c:1679 walk_component+0x2b0/0x3a8 fs/namei.c:1976 link_path_walk+0x590/0xb8c fs/namei.c:-1 path_lookupat+0x90/0x3d0 fs/namei.c:2454 filename_lookup+0x180/0x414 fs/namei.c:2484 kern_path+0x4c/0x190 fs/namei.c:2582 lookup_bdev+0xbc/0x244 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x614/0x908 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x5c/0x98 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x130/0x248 fs/btrfs/super.c:2451 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:860 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584