BTRFS info (device loop0): clearing free space tree BTRFS info (device loop0): clearing compat-ro feature flag for FREE_SPACE_TREE (0x1) BTRFS info (device loop0): clearing compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2) ====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.0.15/5035 is trying to acquire lock: ffff8880256d6650 (sb_internal#2){.+.+}-{0:0}, at: btrfs_dirty_inode+0xc5/0x1c0 fs/btrfs/inode.c:6455 but task is already holding lock: ffff88805c610fe0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:793 [inline] ffff88805c610fe0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: chown_common+0x407/0x680 fs/open.c:674 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&type->i_mutex_dir_key#8){++++}-{3:3}: down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:803 [inline] lookup_slow+0x46/0x70 fs/namei.c:1687 walk_component+0x314/0x460 fs/namei.c:1984 lookup_last fs/namei.c:2439 [inline] path_lookupat+0x148/0x420 fs/namei.c:2463 filename_lookup+0x21e/0x550 fs/namei.c:2492 kern_path+0x37/0x190 fs/namei.c:2633 lookup_bdev+0xc5/0x280 block/bdev.c:978 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x6d9/0xa60 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x52/0x80 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x10a/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 -> #2 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743 btrfs_run_dev_stats+0xeb/0xed0 fs/btrfs/volumes.c:8039 commit_cowonly_roots+0x185/0x9c0 fs/btrfs/transaction.c:1304 btrfs_commit_transaction+0x12d2/0x3580 fs/btrfs/transaction.c:2406 btrfs_clear_free_space_tree+0x772/0xbd0 fs/btrfs/free-space-tree.c:1264 btrfs_start_pre_rw_mount+0x27a/0x620 fs/btrfs/disk-io.c:3056 open_ctree+0x2901/0x3300 fs/btrfs/disk-io.c:3611 btrfs_fill_super+0x1c2/0x2e0 fs/btrfs/super.c:1387 btrfs_mount_root+0x8cb/0x930 fs/btrfs/super.c:1751 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611 vfs_get_tree+0x88/0x270 fs/super.c:1541 fc_mount fs/namespace.c:1005 [inline] vfs_kern_mount+0xba/0x150 fs/namespace.c:1035 btrfs_mount+0x342/0xb10 fs/btrfs/super.c:1811 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611 vfs_get_tree+0x88/0x270 fs/super.c:1541 do_new_mount+0x247/0xa50 fs/namespace.c:3060 do_mount fs/namespace.c:3431 [inline] __do_sys_mount fs/namespace.c:3639 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3616 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 (&fs_info->tree_log_mutex){+.+.}-{3:3}: __lock_release kernel/locking/lockdep.c:5453 [inline] lock_release+0x321/0x8a0 kernel/locking/lockdep.c:5757 __mutex_unlock_slowpath+0xc8/0x6c0 kernel/locking/mutex.c:851 btrfs_commit_transaction+0x1d1a/0x3580 fs/btrfs/transaction.c:2453 btrfs_clear_free_space_tree+0x772/0xbd0 fs/btrfs/free-space-tree.c:1264 btrfs_start_pre_rw_mount+0x27a/0x620 fs/btrfs/disk-io.c:3056 open_ctree+0x2901/0x3300 fs/btrfs/disk-io.c:3611 btrfs_fill_super+0x1c2/0x2e0 fs/btrfs/super.c:1387 btrfs_mount_root+0x8cb/0x930 fs/btrfs/super.c:1751 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611 vfs_get_tree+0x88/0x270 fs/super.c:1541 fc_mount fs/namespace.c:1005 [inline] vfs_kern_mount+0xba/0x150 fs/namespace.c:1035 btrfs_mount+0x342/0xb10 fs/btrfs/super.c:1811 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611 vfs_get_tree+0x88/0x270 fs/super.c:1541 do_new_mount+0x247/0xa50 fs/namespace.c:3060 do_mount fs/namespace.c:3431 [inline] __do_sys_mount fs/namespace.c:3639 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3616 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 (sb_internal#2){.+.+}-{0:0}: check_prev_add kernel/locking/lockdep.c:3120 [inline] check_prevs_add kernel/locking/lockdep.c:3239 [inline] validate_chain kernel/locking/lockdep.c:3855 [inline] __lock_acquire+0x38f7/0x7d40 kernel/locking/lockdep.c:5120 lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5737 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1817 [inline] sb_start_intwrite include/linux/fs.h:1934 [inline] start_transaction+0x5e7/0x11f0 fs/btrfs/transaction.c:692 btrfs_dirty_inode+0xc5/0x1c0 fs/btrfs/inode.c:6455 btrfs_setattr+0x238/0xe20 fs/btrfs/inode.c:5514 notify_change+0xbc6/0xee0 fs/attr.c:505 chown_common+0x4cc/0x680 fs/open.c:680 do_fchownat+0x147/0x240 fs/open.c:711 __do_sys_lchown fs/open.c:736 [inline] __se_sys_lchown fs/open.c:734 [inline] __x64_sys_lchown+0x81/0x90 fs/open.c:734 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: sb_internal#2 --> &fs_devs->device_list_mutex --> &type->i_mutex_dir_key#8 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&type->i_mutex_dir_key#8); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#8); rlock(sb_internal#2); *** DEADLOCK *** 2 locks held by syz.0.15/5035: #0: ffff8880256d6460 (sb_writers#13){.+.+}-{0:0}, at: mnt_want_write+0x3d/0x90 fs/namespace.c:386 #1: ffff88805c610fe0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:793 [inline] #1: ffff88805c610fe0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: chown_common+0x407/0x680 fs/open.c:674 stack backtrace: CPU: 1 PID: 5035 Comm: syz.0.15 Not tainted syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026 Call Trace: dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106 check_noncircular+0x2f8/0x400 kernel/locking/lockdep.c:2178 check_prev_add kernel/locking/lockdep.c:3120 [inline] check_prevs_add kernel/locking/lockdep.c:3239 [inline] validate_chain kernel/locking/lockdep.c:3855 [inline] __lock_acquire+0x38f7/0x7d40 kernel/locking/lockdep.c:5120 lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5737 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1817 [inline] sb_start_intwrite include/linux/fs.h:1934 [inline] start_transaction+0x5e7/0x11f0 fs/btrfs/transaction.c:692 btrfs_dirty_inode+0xc5/0x1c0 fs/btrfs/inode.c:6455 btrfs_setattr+0x238/0xe20 fs/btrfs/inode.c:5514 notify_change+0xbc6/0xee0 fs/attr.c:505 chown_common+0x4cc/0x680 fs/open.c:680 do_fchownat+0x147/0x240 fs/open.c:711 __do_sys_lchown fs/open.c:736 [inline] __se_sys_lchown fs/open.c:734 [inline] __x64_sys_lchown+0x81/0x90 fs/open.c:734 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:0x7f4474b15f69 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f4473d8a058 EFLAGS: 00000246 ORIG_RAX: 000000000000005e RAX: ffffffffffffffda RBX: 00007f4474ce1fa0 RCX: 00007f4474b15f69 RDX: 0000000000000000 RSI: 000000000000ee00 RDI: 0000000020000000 RBP: 00007f4474b99b87 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f4474ce1fa0 R15: 00007ffd346d34a8