BTRFS info (device loop1): enabling ssd optimizations BTRFS info (device loop1): turning on async discard BTRFS info (device loop1): enabling free space tree ====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.1.233/7599 is trying to acquire lock: ffff888062dce770 (sb_internal#2){.+.+}-{0:0}, at: btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6332 but task is already holding lock: ffff88803722b6b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:353 [inline] ffff88803722b6b0 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x214/0x4d0 mm/util.c:579 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&mm->mmap_lock){++++}-{4:4}: down_read_killable+0x9d/0x220 kernel/locking/rwsem.c:1560 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:400 get_mmap_lock_carefully mm/mmap_lock.c:399 [inline] lock_mm_and_find_vma+0x2a8/0x300 mm/mmap_lock.c:450 do_user_addr_fault+0x331/0x1380 arch/x86/mm/fault.c:1359 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x71/0xd0 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 filldir+0x2b6/0x6c0 fs/readdir.c:295 dir_emit include/linux/fs.h:3527 [inline] kernfs_fop_readdir+0x53a/0x870 fs/kernfs/dir.c:1915 iterate_dir+0x3a5/0x580 fs/readdir.c:108 __do_sys_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #4 (&root->kernfs_rwsem){++++}-{4:4}: down_write+0x3a/0x50 kernel/locking/rwsem.c:1590 kernfs_add_one+0x41/0x5c0 fs/kernfs/dir.c:796 kernfs_create_dir_ns+0xde/0x130 fs/kernfs/dir.c:1098 sysfs_create_dir_ns+0x123/0x280 fs/sysfs/dir.c:59 create_dir lib/kobject.c:73 [inline] kobject_add_internal+0x6b1/0xcd0 lib/kobject.c:240 kobject_add_varg lib/kobject.c:374 [inline] kobject_init_and_add+0x125/0x190 lib/kobject.c:457 btrfs_sysfs_add_qgroups+0x111/0x2b0 fs/btrfs/sysfs.c:2697 btrfs_quota_enable+0x25d/0x28f0 fs/btrfs/qgroup.c:1002 btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3613 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}: __mutex_lock_common kernel/locking/rtmutex_api.c:533 [inline] mutex_lock_nested+0x5a/0x1d0 kernel/locking/rtmutex_api.c:552 btrfs_quota_enable+0x29c/0x28f0 fs/btrfs/qgroup.c:1031 btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3613 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (btrfs_trans_num_extwriters){++++}-{0:0}: join_transaction+0x1a4/0xc90 fs/btrfs/transaction.c:323 start_transaction+0x6ba/0x15f0 fs/btrfs/transaction.c:708 btrfs_uuid_scan_kthread+0x570/0xa80 fs/btrfs/uuid-tree.c:425 kthread+0x711/0x8a0 kernel/kthread.c:463 ret_from_fork+0x510/0xa50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246 -> #1 (btrfs_trans_num_writers){++++}-{0:0}: join_transaction+0x182/0xc90 fs/btrfs/transaction.c:322 start_transaction+0x6ba/0x15f0 fs/btrfs/transaction.c:708 btrfs_uuid_scan_kthread+0x570/0xa80 fs/btrfs/uuid-tree.c:425 kthread+0x711/0x8a0 kernel/kthread.c:463 ret_from_fork+0x510/0xa50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246 -> #0 (sb_internal#2){.+.+}-{0:0}: check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain kernel/locking/lockdep.c:3908 [inline] __lock_acquire+0x15a6/0x2cf0 kernel/locking/lockdep.c:5237 lock_acquire+0x107/0x340 kernel/locking/lockdep.c:5868 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs/super.h:19 [inline] sb_start_intwrite include/linux/fs/super.h:177 [inline] start_transaction+0x56f/0x15f0 fs/btrfs/transaction.c:702 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6332 inode_update_time fs/inode.c:2167 [inline] touch_atime+0x2f9/0x6d0 fs/inode.c:2240 file_accessed include/linux/fs.h:2254 [inline] btrfs_file_mmap_prepare+0x189/0x200 fs/btrfs/file.c:2053 vfs_mmap_prepare include/linux/fs.h:2058 [inline] call_mmap_prepare mm/vma.c:2596 [inline] __mmap_region mm/vma.c:2692 [inline] mmap_region+0xb4c/0x1d00 mm/vma.c:2786 do_mmap+0xc23/0x10c0 mm/mmap.c:558 vm_mmap_pgoff+0x2a9/0x4d0 mm/util.c:581 ksys_mmap_pgoff+0x4e9/0x720 mm/mmap.c:604 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xec/0xf80 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: sb_internal#2 --> &root->kernfs_rwsem --> &mm->mmap_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mm->mmap_lock); lock(&root->kernfs_rwsem); lock(&mm->mmap_lock); rlock(sb_internal#2); *** DEADLOCK *** 2 locks held by syz.1.233/7599: #0: ffff88803722b6b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:353 [inline] #0: ffff88803722b6b0 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x214/0x4d0 mm/util.c:579 #1: ffff888062dce480 (sb_writers#15){.+.+}-{0:0}, at: file_accessed include/linux/fs.h:2254 [inline] #1: ffff888062dce480 (sb_writers#15){.+.+}-{0:0}, at: btrfs_file_mmap_prepare+0x189/0x200 fs/btrfs/file.c:2053 stack backtrace: CPU: 1 UID: 0 PID: 7599 Comm: syz.1.233 Not tainted syzkaller #0 PREEMPT_{RT,(full)} Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025 Call Trace: dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_circular_bug+0x2e2/0x300 kernel/locking/lockdep.c:2043 check_noncircular+0x12e/0x150 kernel/locking/lockdep.c:2175 check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain kernel/locking/lockdep.c:3908 [inline] __lock_acquire+0x15a6/0x2cf0 kernel/locking/lockdep.c:5237 lock_acquire+0x107/0x340 kernel/locking/lockdep.c:5868 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs/super.h:19 [inline] sb_start_intwrite include/linux/fs/super.h:177 [inline] start_transaction+0x56f/0x15f0 fs/btrfs/transaction.c:702 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6332 inode_update_time fs/inode.c:2167 [inline] touch_atime+0x2f9/0x6d0 fs/inode.c:2240 file_accessed include/linux/fs.h:2254 [inline] btrfs_file_mmap_prepare+0x189/0x200 fs/btrfs/file.c:2053 vfs_mmap_prepare include/linux/fs.h:2058 [inline] call_mmap_prepare mm/vma.c:2596 [inline] __mmap_region mm/vma.c:2692 [inline] mmap_region+0xb4c/0x1d00 mm/vma.c:2786 do_mmap+0xc23/0x10c0 mm/mmap.c:558 vm_mmap_pgoff+0x2a9/0x4d0 mm/util.c:581 ksys_mmap_pgoff+0x4e9/0x720 mm/mmap.c:604 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f47b6aaf749 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:00007f47b4d16038 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: ffffffffffffffda RBX: 00007f47b6d05fa0 RCX: 00007f47b6aaf749 RDX: 0000000000000001 RSI: 0000000000004000 RDI: 0000200000000000 RBP: 00007f47b6b33f91 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000010012 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f47b6d06038 R14: 00007f47b6d05fa0 R15: 00007fffb78ff048 BTRFS warning (device loop1): failed to trim 1 device(s), last error -512