BTRFS info (device loop3): using free space tree
BTRFS info (device loop3): enabling ssd optimizations
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc6-syzkaller-00315-gfaf68e3523c2 #0 Not tainted
------------------------------------------------------
syz-executor.3/8835 is trying to acquire lock:
ffff8880773bc6c8 (btrfs-tree-01){++++}-{3:3}, at: __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
ffff8880773bc6c8 (btrfs-tree-01){++++}-{3:3}, at: btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
ffff8880773bc6c8 (btrfs-tree-01){++++}-{3:3}, at: btrfs_read_lock_root_node+0x2b4/0x400 fs/btrfs/locking.c:279

but task is already holding lock:
ffff88801d71b458 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
ffff88801d71b458 (btrfs-tree-00){++++}-{3:3}, at: btrfs_tree_read_lock+0x1e/0x40 fs/btrfs/locking.c:140

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (btrfs-tree-00){++++}-{3:3}:
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       down_read_nested+0x3c/0x50 kernel/locking/rwsem.c:1634
       __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
       btrfs_tree_read_lock+0x1e/0x40 fs/btrfs/locking.c:140
       btrfs_search_slot+0x1707/0x2fb0 fs/btrfs/ctree.c:2133
       btrfs_init_root_free_objectid+0x141/0x330 fs/btrfs/disk-io.c:5268
       btrfs_init_fs_root fs/btrfs/disk-io.c:1467 [inline]
       btrfs_get_root_ref+0x6bc/0xe00 fs/btrfs/disk-io.c:1671
       btrfs_get_fs_root fs/btrfs/disk-io.c:1723 [inline]
       open_ctree+0x2789/0x2d94 fs/btrfs/disk-io.c:3781
       btrfs_fill_super+0x1c6/0x2d0 fs/btrfs/super.c:1461
       btrfs_mount_root+0x88e/0x9a0 fs/btrfs/super.c:1829
       legacy_get_tree+0xea/0x180 fs/fs_context.c:610
       vfs_get_tree+0x88/0x270 fs/super.c:1531
       fc_mount fs/namespace.c:1043 [inline]
       vfs_kern_mount+0xc9/0x160 fs/namespace.c:1073
       btrfs_mount+0x3de/0xbf0 fs/btrfs/super.c:1889
       legacy_get_tree+0xea/0x180 fs/fs_context.c:610
       vfs_get_tree+0x88/0x270 fs/super.c:1531
       do_new_mount+0x289/0xad0 fs/namespace.c:3040
       do_mount fs/namespace.c:3383 [inline]
       __do_sys_mount fs/namespace.c:3591 [inline]
       __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3568
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (btrfs-tree-01){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       down_read_nested+0x3c/0x50 kernel/locking/rwsem.c:1634
       __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
       btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
       btrfs_read_lock_root_node+0x2b4/0x400 fs/btrfs/locking.c:279
       btrfs_search_slot_get_root fs/btrfs/ctree.c:1665 [inline]
       btrfs_search_slot+0x4eb/0x2fb0 fs/btrfs/ctree.c:1985
       btrfs_lookup_inode+0xd8/0x470 fs/btrfs/inode-item.c:407
       btrfs_read_locked_inode fs/btrfs/inode.c:3958 [inline]
       btrfs_iget_path+0x2f7/0x1430 fs/btrfs/inode.c:5737
       btrfs_search_path_in_tree_user fs/btrfs/ioctl.c:2851 [inline]
       btrfs_ioctl_ino_lookup_user+0x768/0xf40 fs/btrfs/ioctl.c:2995
       btrfs_ioctl+0xb91/0xc10 fs/btrfs/ioctl.c:5561
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(btrfs-tree-00);
                               lock(btrfs-tree-01);
                               lock(btrfs-tree-00);
  lock(btrfs-tree-01);

 *** DEADLOCK ***

1 lock held by syz-executor.3/8835:
 #0: ffff88801d71b458 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
 #0: ffff88801d71b458 (btrfs-tree-00){++++}-{3:3}, at: btrfs_tree_read_lock+0x1e/0x40 fs/btrfs/locking.c:140

stack backtrace:
CPU: 1 PID: 8835 Comm: syz-executor.3 Not tainted 6.1.0-rc6-syzkaller-00315-gfaf68e3523c2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2f9/0x3b0 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
 down_read_nested+0x3c/0x50 kernel/locking/rwsem.c:1634
 __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
 btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
 btrfs_read_lock_root_node+0x2b4/0x400 fs/btrfs/locking.c:279
 btrfs_search_slot_get_root fs/btrfs/ctree.c:1665 [inline]
 btrfs_search_slot+0x4eb/0x2fb0 fs/btrfs/ctree.c:1985
 btrfs_lookup_inode+0xd8/0x470 fs/btrfs/inode-item.c:407
 btrfs_read_locked_inode fs/btrfs/inode.c:3958 [inline]
 btrfs_iget_path+0x2f7/0x1430 fs/btrfs/inode.c:5737
 btrfs_search_path_in_tree_user fs/btrfs/ioctl.c:2851 [inline]
 btrfs_ioctl_ino_lookup_user+0x768/0xf40 fs/btrfs/ioctl.c:2995
 btrfs_ioctl+0xb91/0xc10 fs/btrfs/ioctl.c:5561
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f9f5288c0d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9f53605168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f9f529abf80 RCX: 00007f9f5288c0d9
RDX: 0000000020000080 RSI: 00000000d000943e RDI: 0000000000000004
RBP: 00007f9f528e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc0f67c49f R14: 00007f9f53605300 R15: 0000000000022000
 </TASK>