======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/u10:7/1091 is trying to acquire lock:
ffff88810b87bb78 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}, at: hfs_extend_file+0xda/0x1540

but task is already holding lock:
ffff8881104820b0 (&tree->tree_lock/1){+.+.}-{4:4}, at: hfs_find_init+0x18e/0x300

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock/1){+.+.}-{4:4}:
       __mutex_lock+0x187/0x1350
       hfs_find_init+0x18e/0x300
       hfs_extend_file+0x2f6/0x1540
       hfs_bmap_reserve+0x107/0x430
       hfs_cat_create+0x1c5/0x770
       hfs_create+0x66/0xe0
       path_openat+0x18bb/0x3dd0
       do_filp_open+0x1fa/0x410
       do_sys_openat2+0x121/0x200
       __x64_sys_open+0x11e/0x150
       do_syscall_64+0xec/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}:
       __lock_acquire+0x15a6/0x2cf0
       lock_acquire+0x107/0x340
       __mutex_lock+0x187/0x1350
       hfs_extend_file+0xda/0x1540
       hfs_bmap_reserve+0x107/0x430
       __hfs_ext_write_extent+0x1fa/0x470
       hfs_ext_write_extent+0x161/0x1e0
       hfs_write_inode+0xc6/0x8a0
       __writeback_single_inode+0x7e1/0x1240
       writeback_sb_inodes+0x93a/0x1870
       wb_writeback+0x42b/0xaa0
       wb_workfn+0x3f9/0xed0
       process_scheduled_works+0xad1/0x1770
       worker_thread+0x8a0/0xda0
       kthread+0x711/0x8a0
       ret_from_fork+0x510/0xa50
       ret_from_fork_asm+0x1a/0x30

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&tree->tree_lock/1);
                               lock(&HFS_I(tree->inode)->extents_lock);
                               lock(&tree->tree_lock/1);
  lock(&HFS_I(tree->inode)->extents_lock);

 *** DEADLOCK ***

3 locks held by kworker/u10:7/1091:
 #0: ffff888161af5948 ((wq_completion)writeback){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x1770
 #1: ffffc90008317bc0 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x1770
 #2: ffff8881104820b0 (&tree->tree_lock/1){+.+.}-{4:4}, at: hfs_find_init+0x18e/0x300

stack backtrace:
CPU: 1 UID: 0 PID: 1091 Comm: kworker/u10:7 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: writeback wb_workfn (flush-7:9)
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_circular_bug+0x2e2/0x300
 check_noncircular+0x12e/0x150
 __lock_acquire+0x15a6/0x2cf0
 lock_acquire+0x107/0x340
 __mutex_lock+0x187/0x1350
 hfs_extend_file+0xda/0x1540
 hfs_bmap_reserve+0x107/0x430
 __hfs_ext_write_extent+0x1fa/0x470
 hfs_ext_write_extent+0x161/0x1e0
 hfs_write_inode+0xc6/0x8a0
 __writeback_single_inode+0x7e1/0x1240
 writeback_sb_inodes+0x93a/0x1870
 wb_writeback+0x42b/0xaa0
 wb_workfn+0x3f9/0xed0
 process_scheduled_works+0xad1/0x1770
 worker_thread+0x8a0/0xda0
 kthread+0x711/0x8a0
 ret_from_fork+0x510/0xa50
 ret_from_fork_asm+0x1a/0x30
 </TASK>
hfs: new node 0 already hashed?
------------[ cut here ]------------
WARNING: fs/hfs/bnode.c:520 at hfs_bnode_create+0x461/0x4f0, CPU#1: kworker/u10:7/1091
Modules linked in:
CPU: 1 UID: 0 PID: 1091 Comm: kworker/u10:7 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: writeback wb_workfn (flush-7:9)
RIP: 0010:hfs_bnode_create+0x461/0x4f0
Code: 82 8b 89 ee e8 00 b1 86 fe e9 cf fc ff ff e8 46 ff 1f ff 4c 89 ef e8 fe 2f bb 08 48 c7 c7 c0 b5 82 8b 89 ee e8 e0 b0 86 fe 90 <0f> 0b 90 eb b0 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c d6 fb ff ff
RSP: 0018:ffffc90008316c20 EFLAGS: 00010246
RAX: 000000000000001f RBX: ffff888110482000 RCX: 40f53d503dcb1e00
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffc900083169a7 R09: 1ffff92001062d34
R10: dffffc0000000000 R11: fffff52001062d35 R12: 0000000000000000
R13: ffff8881104820e0 R14: ffff88816e263300 R15: dffffc0000000000
FS:  0000000000000000(0000) GS:ffff8882a9e21000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fda04b61fc8 CR3: 00000001145b4000 CR4: 00000000000006f0
Call Trace:
 <TASK>
 hfs_bmap_alloc+0x5bb/0x640
 hfs_btree_inc_height+0xf6/0xac0
 hfs_brec_insert+0x7ee/0xc80
 __hfs_ext_write_extent+0x2a1/0x470
 hfs_ext_write_extent+0x161/0x1e0
 hfs_write_inode+0xc6/0x8a0
 __writeback_single_inode+0x7e1/0x1240
 writeback_sb_inodes+0x93a/0x1870
 wb_writeback+0x42b/0xaa0
 wb_workfn+0x3f9/0xed0
 process_scheduled_works+0xad1/0x1770
 worker_thread+0x8a0/0xda0
 kthread+0x711/0x8a0
 ret_from_fork+0x510/0xa50
 ret_from_fork_asm+0x1a/0x30
 </TASK>
