====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ kworker/u8:3/57 is trying to acquire lock: ffff888095e87118 (btrfs_trans_num_writers){++++}-{0:0}, at: join_transaction+0x41b/0xc90 fs/btrfs/transaction.c:298 but task is already holding lock: ffff888087df0770 (sb_internal#5){.+.+}-{0:0}, at: __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (sb_internal#5){.+.+}-{0:0}: 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+0x56e/0x1650 fs/btrfs/transaction.c:702 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6443 touch_atime+0x2f8/0x6b0 fs/inode.c:2271 file_accessed include/linux/fs.h:2263 [inline] btrfs_file_mmap_prepare+0x189/0x200 fs/btrfs/file.c:2051 vfs_mmap_prepare include/linux/fs.h:2075 [inline] call_mmap_prepare mm/vma.c:2644 [inline] __mmap_region mm/vma.c:2743 [inline] mmap_region+0xddc/0x2230 mm/vma.c:2837 do_mmap+0xc2f/0x10c0 mm/mmap.c:559 vm_mmap_pgoff+0x2cc/0x4f0 mm/util.c:581 ksys_mmap_pgoff+0x4e8/0x720 mm/mmap.c:605 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #4 (&mm->mmap_lock){++++}-{4:4}: down_read_killable+0xa4/0x220 kernel/locking/rwsem.c:1560 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:601 get_mmap_lock_carefully mm/mmap_lock.c:450 [inline] lock_mm_and_find_vma+0x2d7/0x340 mm/mmap_lock.c:501 do_user_addr_fault+0x330/0x1340 arch/x86/mm/fault.c:1357 handle_page_fault arch/x86/mm/fault.c:1474 [inline] exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 filldir64+0x2cd/0x670 fs/readdir.c:-1 dir_emit include/linux/fs.h:3566 [inline] kernfs_fop_readdir+0x57e/0x8d0 fs/kernfs/dir.c:1915 iterate_dir+0x3a5/0x580 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:412 [inline] __se_sys_getdents64+0xf1/0x280 fs/readdir.c:397 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&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+0x12f/0x2a0 fs/sysfs/dir.c:59 create_dir lib/kobject.c:73 [inline] kobject_add_internal+0x631/0xd10 lib/kobject.c:240 kobject_add_varg lib/kobject.c:374 [inline] kobject_init_and_add+0x12b/0x1a0 lib/kobject.c:457 btrfs_sysfs_add_qgroups+0x116/0x2e0 fs/btrfs/sysfs.c:2604 btrfs_quota_enable+0x282/0x2850 fs/btrfs/qgroup.c:1034 btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540 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+0x14d/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (&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+0x2c6/0x2850 fs/btrfs/qgroup.c:1063 btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540 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+0x14d/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (btrfs_trans_num_extwriters){++++}-{0:0}: join_transaction+0x1a4/0xc90 fs/btrfs/transaction.c:323 start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708 btrfs_rebuild_free_space_tree+0xbb/0x6e0 fs/btrfs/free-space-tree.c:1335 btrfs_start_pre_rw_mount+0x1529/0x1f20 fs/btrfs/disk-io.c:3071 open_ctree+0x2e07/0x4220 fs/btrfs/disk-io.c:3668 btrfs_fill_super fs/btrfs/super.c:981 [inline] btrfs_get_tree_super fs/btrfs/super.c:1944 [inline] btrfs_get_tree_subvol fs/btrfs/super.c:2087 [inline] btrfs_get_tree+0x1061/0x1930 fs/btrfs/super.c:2121 vfs_get_tree+0x92/0x2a0 fs/super.c:1754 fc_mount fs/namespace.c:1193 [inline] do_new_mount_fc fs/namespace.c:3763 [inline] do_new_mount+0x341/0xd30 fs/namespace.c:3839 do_mount fs/namespace.c:4172 [inline] __do_sys_mount fs/namespace.c:4361 [inline] __se_sys_mount+0x31d/0x420 fs/namespace.c:4338 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (btrfs_trans_num_writers){++++}-{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+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237 lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868 join_transaction+0x43b/0xc90 fs/btrfs/transaction.c:298 start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708 __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646 cow_file_range_inline+0x3b5/0x4b0 fs/btrfs/inode.c:724 compress_file_range+0xcba/0x19b0 fs/btrfs/inode.c:1054 btrfs_work_helper+0x38b/0xc70 fs/btrfs/async-thread.c:312 process_one_work kernel/workqueue.c:3276 [inline] process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359 worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 other info that might help us debug this: Chain exists of: btrfs_trans_num_writers --> &mm->mmap_lock --> sb_internal#5 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(sb_internal#5); lock(&mm->mmap_lock); lock(sb_internal#5); rlock(btrfs_trans_num_writers); *** DEADLOCK *** 3 locks held by kworker/u8:3/57: #0: ffff88805e008138 ((wq_completion)btrfs-delalloc#34){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3251 [inline] #0: ffff88805e008138 ((wq_completion)btrfs-delalloc#34){+.+.}-{0:0}, at: process_scheduled_works+0xa52/0x18c0 kernel/workqueue.c:3359 #1: ffffc9000123fc40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3252 [inline] #1: ffffc9000123fc40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa8d/0x18c0 kernel/workqueue.c:3359 #2: ffff888087df0770 (sb_internal#5){.+.+}-{0:0}, at: __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646 stack backtrace: CPU: 1 UID: 0 PID: 57 Comm: kworker/u8:3 Not tainted syzkaller #0 PREEMPT_{RT,(full)} Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026 Workqueue: btrfs-delalloc btrfs_work_helper Call Trace: dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_circular_bug+0x2e1/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+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237 lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868 join_transaction+0x43b/0xc90 fs/btrfs/transaction.c:298 start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708 __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646 cow_file_range_inline+0x3b5/0x4b0 fs/btrfs/inode.c:724 compress_file_range+0xcba/0x19b0 fs/btrfs/inode.c:1054 btrfs_work_helper+0x38b/0xc70 fs/btrfs/async-thread.c:312 process_one_work kernel/workqueue.c:3276 [inline] process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359 worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245