BTRFS info (device loop1): enabling ssd optimizations
BTRFS info (device loop1): auto enabling async discard
======================================================
WARNING: possible circular locking dependency detected
6.3.0-rc6-syzkaller-00035-g0bcc40255504 #0 Not tainted
------------------------------------------------------
syz-executor.1/14972 is trying to acquire lock:
ffff88801ad01268 (btrfs-tree-01){++++}-{3:3}, at: __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135

but task is already holding lock:
ffff88801ad00e88 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (btrfs-tree-00){++++}-{3:3}:
       lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
       down_read_nested+0x40/0x60 kernel/locking/rwsem.c:1645
       __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135
       btrfs_search_slot+0x16ba/0x2f70 fs/btrfs/ctree.c:2244
       btrfs_init_root_free_objectid+0x148/0x320 fs/btrfs/disk-io.c:5208
       btrfs_init_fs_root fs/btrfs/disk-io.c:1378 [inline]
       btrfs_get_root_ref+0x5ce/0xba0 fs/btrfs/disk-io.c:1582
       btrfs_get_fs_root fs/btrfs/disk-io.c:1634 [inline]
       open_ctree+0x28fb/0x2f40 fs/btrfs/disk-io.c:3720
       btrfs_fill_super+0x1c7/0x2d0 fs/btrfs/super.c:1152
       btrfs_mount_root+0x80f/0x950 fs/btrfs/super.c:1519
       legacy_get_tree+0xef/0x190 fs/fs_context.c:610
       vfs_get_tree+0x8c/0x270 fs/super.c:1510
       fc_mount fs/namespace.c:1035 [inline]
       vfs_kern_mount+0xbc/0x150 fs/namespace.c:1065
       btrfs_mount+0x39f/0xb50 fs/btrfs/super.c:1579
       legacy_get_tree+0xef/0x190 fs/fs_context.c:610
       vfs_get_tree+0x8c/0x270 fs/super.c:1510
       do_new_mount+0x28f/0xae0 fs/namespace.c:3042
       do_mount fs/namespace.c:3385 [inline]
       __do_sys_mount fs/namespace.c:3594 [inline]
       __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x41/0xc0 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:3098 [inline]
       check_prevs_add kernel/locking/lockdep.c:3217 [inline]
       validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
       lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
       down_read_nested+0x40/0x60 kernel/locking/rwsem.c:1645
       __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135
       btrfs_tree_read_lock fs/btrfs/locking.c:141 [inline]
       btrfs_read_lock_root_node+0x292/0x3c0 fs/btrfs/locking.c:280
       btrfs_search_slot_get_root fs/btrfs/ctree.c:1774 [inline]
       btrfs_search_slot+0x571/0x2f70 fs/btrfs/ctree.c:2096
       btrfs_lookup_inode+0xdc/0x480 fs/btrfs/inode-item.c:412
       btrfs_read_locked_inode fs/btrfs/inode.c:3830 [inline]
       btrfs_iget_path+0x2d9/0x1520 fs/btrfs/inode.c:5649
       btrfs_search_path_in_tree_user fs/btrfs/ioctl.c:1960 [inline]
       btrfs_ioctl_ino_lookup_user+0x774/0xf50 fs/btrfs/ioctl.c:2104
       btrfs_ioctl+0xb08/0xd40 fs/btrfs/ioctl.c:4671
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x41/0xc0 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.1/14972:
 #0: ffff88801ad00e88 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135

stack backtrace:
CPU: 0 PID: 14972 Comm: syz-executor.1 Not tainted 6.3.0-rc6-syzkaller-00035-g0bcc40255504 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2fe/0x3b0 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3098 [inline]
 check_prevs_add kernel/locking/lockdep.c:3217 [inline]
 validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
 lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
 down_read_nested+0x40/0x60 kernel/locking/rwsem.c:1645
 __btrfs_tree_read_lock+0x2f/0x220 fs/btrfs/locking.c:135
 btrfs_tree_read_lock fs/btrfs/locking.c:141 [inline]
 btrfs_read_lock_root_node+0x292/0x3c0 fs/btrfs/locking.c:280
 btrfs_search_slot_get_root fs/btrfs/ctree.c:1774 [inline]
 btrfs_search_slot+0x571/0x2f70 fs/btrfs/ctree.c:2096
 btrfs_lookup_inode+0xdc/0x480 fs/btrfs/inode-item.c:412
 btrfs_read_locked_inode fs/btrfs/inode.c:3830 [inline]
 btrfs_iget_path+0x2d9/0x1520 fs/btrfs/inode.c:5649
 btrfs_search_path_in_tree_user fs/btrfs/ioctl.c:1960 [inline]
 btrfs_ioctl_ino_lookup_user+0x774/0xf50 fs/btrfs/ioctl.c:2104
 btrfs_ioctl+0xb08/0xd40 fs/btrfs/ioctl.c:4671
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f482ea8c169
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:00007f482f7d9168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f482ebabf80 RCX: 00007f482ea8c169
RDX: 00000000200001c0 RSI: 00000000d000943e RDI: 0000000000000004
RBP: 00007f482eae7ca1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd02d726ff R14: 00007f482f7d9300 R15: 0000000000022000
 </TASK>