======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G             L     
------------------------------------------------------
syz.5.986/9873 is trying to acquire lock:
ffff888117e09458 (&ocfs2_file_ip_alloc_sem_key){++++}-{4:4}, at: ocfs2_try_remove_refcount_tree+0xb6/0x360

but task is already holding lock:
ffff888117e094e8 (&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_try_remove_refcount_tree+0xa4/0x360

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&oi->ip_xattr_sem){++++}-{4:4}:
       down_read+0x4a/0x330
       ocfs2_init_acl+0x2fd/0x7e0
       ocfs2_mknod+0x166a/0x2240
       ocfs2_create+0x195/0x460
       path_openat+0x133a/0x3830
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_creat+0x8f/0xc0
       do_syscall_64+0x174/0x580
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&journal->j_trans_barrier){.+.+}-{4:4}:
       down_read+0x4a/0x330
       ocfs2_start_trans+0x3ab/0x700
       ocfs2_shutdown_local_alloc+0x1ef/0xa50
       ocfs2_dismount_volume+0x1ec/0x8d0
       generic_shutdown_super+0x13d/0x2d0
       kill_block_super+0x44/0x90
       deactivate_locked_super+0xbc/0x130
       cleanup_mnt+0x3d3/0x460
       task_work_run+0x1d9/0x270
       do_exit+0x73a/0x2360
       do_group_exit+0x22d/0x2f0
       get_signal+0x121b/0x12c0
       arch_do_signal_or_restart+0xbb/0x860
       exit_to_user_mode_loop+0x104/0x730
       do_syscall_64+0x353/0x580
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (sb_internal#3){.+.+}-{0:0}:
       ocfs2_start_trans+0x2ac/0x700
       ocfs2_truncate_file+0x634/0x14b0
       ocfs2_setattr+0x1641/0x1d10
       notify_change+0xbba/0xea0
       do_truncate+0x1c2/0x250
       vfs_coredump+0x3775/0x44b0
       get_signal+0x1094/0x12c0
       arch_do_signal_or_restart+0xbb/0x860
       irqentry_exit+0x2ba/0x8f0
       asm_exc_page_fault+0x26/0x30

-> #0 (&ocfs2_file_ip_alloc_sem_key){++++}-{4:4}:
       __lock_acquire+0x15ff/0x2e50
       lock_acquire+0x115/0x350
       down_write+0x96/0x200
       ocfs2_try_remove_refcount_tree+0xb6/0x360
       ocfs2_truncate_file+0xe90/0x14b0
       ocfs2_setattr+0x1641/0x1d10
       notify_change+0xbba/0xea0
       do_truncate+0x1c2/0x250
       vfs_coredump+0x3775/0x44b0
       get_signal+0x1094/0x12c0
       arch_do_signal_or_restart+0xbb/0x860
       irqentry_exit+0x2ba/0x8f0
       asm_exc_page_fault+0x26/0x30

other info that might help us debug this:

Chain exists of:
  &ocfs2_file_ip_alloc_sem_key --> &journal->j_trans_barrier --> &oi->ip_xattr_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&oi->ip_xattr_sem);
                               lock(&journal->j_trans_barrier);
                               lock(&oi->ip_xattr_sem);
  lock(&ocfs2_file_ip_alloc_sem_key);

 *** DEADLOCK ***

2 locks held by syz.5.986/9873:
 #0: ffff888117e097a0 (&sb->s_type->i_mutex_key#32){+.+.}-{4:4}, at: do_truncate+0x18f/0x250
 #1: ffff888117e094e8 (&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_try_remove_refcount_tree+0xa4/0x360

stack backtrace:
CPU: 0 UID: 0 PID: 9873 Comm: syz.5.986 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_circular_bug+0x2e2/0x300
 check_noncircular+0x12f/0x150
 __lock_acquire+0x15ff/0x2e50
 lock_acquire+0x115/0x350
 down_write+0x96/0x200
 ocfs2_try_remove_refcount_tree+0xb6/0x360
 ocfs2_truncate_file+0xe90/0x14b0
 ocfs2_setattr+0x1641/0x1d10
 notify_change+0xbba/0xea0
 do_truncate+0x1c2/0x250
 vfs_coredump+0x3775/0x44b0
 get_signal+0x1094/0x12c0
 arch_do_signal_or_restart+0xbb/0x860
 irqentry_exit+0x2ba/0x8f0
 asm_exc_page_fault+0x26/0x30
RIP: 0033:0x7f15d5053bd7
Code: e8 fe f9 ff ff 89 f2 48 8d 3d 5d 4f 1b 00 48 8d 35 c3 0a 1e 00 31 c0 e8 37 f8 ff ff 0f 1f 80 00 00 00 00 53 89 fb 48 83 ec 10 <64> 8b 04 25 a4 ff ff ff 85 c0 74 2a 89 fe 31 c0 bf 3c 00 00 00 e8
RSP: 002b:00007f15d60d20a0 EFLAGS: 00010206
RAX: 0000000000000000 RBX: 000000000000000b RCX: 00007f15d519e0d9
RDX: 00007f15d60d20c0 RSI: 00007f15d60d21f0 RDI: 000000000000000b
RBP: 00007f15d5235024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007f15d5426038 R14: 00007f15d5425fa0 R15: 00007fff1eb62328
 </TASK>
OCFS2: ERROR (device loop5): int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *, handle_t *, u32, u32, struct ocfs2_suballoc_result *): Chain allocator dinode 71 has 16777215 used bits but only 1024 total
On-disk corruption discovered. Please run fsck.ocfs2 once the filesystem is unmounted.
OCFS2: File system is now read-only.
(syz.5.986,9873,0):ocfs2_claim_suballoc_bits:2198 ERROR: status = -30
(syz.5.986,9873,0):__ocfs2_claim_clusters:2579 ERROR: status = -30
(syz.5.986,9873,0):__ocfs2_claim_clusters:2587 ERROR: status = -30
(syz.5.986,9873,0):ocfs2_convert_inline_data_to_extents:7146 ERROR: status = -30
(syz.5.986,9873,0):ocfs2_try_to_write_inline_data:1545 ERROR: status = -30
(syz.5.986,9873,0):ocfs2_write_begin_nolock:1657 ERROR: status = -30
(syz.5.986,9873,0):ocfs2_write_begin:1888 ERROR: status = -30
