loop8: detected capacity change from 0 to 512
EXT4-fs: Ignoring removed mblk_io_submit option
EXT4-fs: Ignoring removed nobh option
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G             L     
------------------------------------------------------
syz.8.3467/14835 is trying to acquire lock:
ffff88801eb22c18 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_writepages+0x205/0x3b0

but task is already holding lock:
ffff888107b52fa0 (&ei->xattr_sem){++++}-{4:4}, at: __ext4_mark_inode_dirty+0x3d0/0x700

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ei->xattr_sem){++++}-{4:4}:
       down_write+0x96/0x200
       ext4_destroy_inline_data+0x28/0xe0
       ext4_do_writepages+0x573/0x47a0
       ext4_writepages+0x241/0x3b0
       do_writepages+0x338/0x560
       file_write_and_wait_range+0x36e/0x440
       mmb_fsync_noflush+0x73/0x1d0
       ext4_sync_file+0x41a/0xd00
       ext4_buffered_write_iter+0x2c7/0x370
       ext4_file_write_iter+0x947/0x1c70
       do_iter_readv_writev+0x612/0x8c0
       vfs_writev+0x343/0x990
       __se_sys_pwritev2+0x177/0x2a0
       do_syscall_64+0x174/0x580
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&sbi->s_writepages_rwsem){++++}-{0:0}:
       __lock_acquire+0x15ff/0x2e50
       lock_acquire+0x115/0x350
       percpu_down_read_internal+0x48/0x1c0
       ext4_writepages+0x205/0x3b0
       do_writepages+0x338/0x560
       __writeback_single_inode+0x12e/0xf90
       writeback_single_inode+0x4ef/0xe70
       write_inode_now+0x1c2/0x290
       iput+0x98b/0xf00
       ext4_xattr_block_set+0x1b0c/0x2a80
       ext4_expand_extra_isize_ea+0x1342/0x1e70
       __ext4_expand_extra_isize+0x30d/0x400
       __ext4_mark_inode_dirty+0x455/0x700
       ext4_evict_inode+0x976/0x10c0
       evict+0x624/0xb50
       ext4_orphan_cleanup+0xc7a/0x14c0
       ext4_fill_super+0x5cb4/0x65c0
       get_tree_bdev_flags+0x430/0x4f0
       vfs_get_tree+0x92/0x2a0
       do_new_mount+0x319/0xdc0
       __se_sys_mount+0x31d/0x420
       do_syscall_64+0x174/0x580
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ei->xattr_sem);
                               lock(&sbi->s_writepages_rwsem);
                               lock(&ei->xattr_sem);
  rlock(&sbi->s_writepages_rwsem);

 *** DEADLOCK ***

3 locks held by syz.8.3467/14835:
 #0: ffff88801eb260d8 (&type->s_umount_key#28/1){+.+.}-{4:4}, at: sget_fc+0x938/0x1900
 #1: ffff88801eb26640 (sb_internal){.+.+}-{0:0}, at: ext4_evict_inode+0x426/0x10c0
 #2: ffff888107b52fa0 (&ei->xattr_sem){++++}-{4:4}, at: __ext4_mark_inode_dirty+0x3d0/0x700

stack backtrace:
CPU: 1 UID: 0 PID: 14835 Comm: syz.8.3467 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
 percpu_down_read_internal+0x48/0x1c0
 ext4_writepages+0x205/0x3b0
 do_writepages+0x338/0x560
 __writeback_single_inode+0x12e/0xf90
 writeback_single_inode+0x4ef/0xe70
 write_inode_now+0x1c2/0x290
 iput+0x98b/0xf00
 ext4_xattr_block_set+0x1b0c/0x2a80
 ext4_expand_extra_isize_ea+0x1342/0x1e70
 __ext4_expand_extra_isize+0x30d/0x400
 __ext4_mark_inode_dirty+0x455/0x700
 ext4_evict_inode+0x976/0x10c0
 evict+0x624/0xb50
 ext4_orphan_cleanup+0xc7a/0x14c0
 ext4_fill_super+0x5cb4/0x65c0
 get_tree_bdev_flags+0x430/0x4f0
 vfs_get_tree+0x92/0x2a0
 do_new_mount+0x319/0xdc0
 __se_sys_mount+0x31d/0x420
 do_syscall_64+0x174/0x580
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd58ab9f34a
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd58ba1be58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fd58ba1bee0 RCX: 00007fd58ab9f34a
RDX: 0000200000000180 RSI: 0000200000000080 RDI: 00007fd58ba1bea0
RBP: 0000200000000180 R08: 00007fd58ba1bee0 R09: 0000000000800718
R10: 0000000000800718 R11: 0000000000000246 R12: 0000200000000080
R13: 00007fd58ba1bea0 R14: 00000000000004a7 R15: 000000000000002c
 </TASK>
------------[ cut here ]------------
EA inode 11 i_nlink=1026
WARNING: fs/ext4/xattr.c:1059 at ext4_xattr_inode_update_ref+0x4cc/0x590, CPU#1: syz.8.3467/14835
Modules linked in:
CPU: 1 UID: 0 PID: 14835 Comm: syz.8.3467 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
RIP: 0010:ext4_xattr_inode_update_ref+0x50c/0x590
Code: 08 4c 89 e7 e8 15 7a 94 ff 4d 8b 24 24 48 b8 00 00 00 00 00 fc ff df 41 0f b6 04 07 84 c0 75 73 41 8b 55 00 48 89 df 4c 89 e6 <67> 48 0f b9 3a e9 5f fe ff ff e8 25 16 2f 09 44 89 e9 80 e1 07 80
RSP: 0018:ffffc9000765f120 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffffffff905e2a40 RCX: dffffc0000000000
RDX: 0000000000000402 RSI: 000000000000000b RDI: ffffffff905e2a40
RBP: ffffc9000765f218 R08: ffff88817420330f R09: 1ffff1102e840661
R10: dffffc0000000000 R11: ffffed102e840662 R12: 000000000000000b
R13: ffff888174203168 R14: 0000000000000000 R15: 1ffff1102e84062d
FS:  00007fd58ba1c6c0(0000) GS:ffff8882a8f5c000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b34b18ff8 CR3: 000000010eef2000 CR4: 00000000000006f0
Call Trace:
 <TASK>
 ext4_xattr_set_entry+0xb19/0x1ed0
 ext4_xattr_ibody_set+0x262/0x710
 ext4_expand_extra_isize_ea+0x138c/0x1e70
 __ext4_expand_extra_isize+0x30d/0x400
 __ext4_mark_inode_dirty+0x455/0x700
 ext4_evict_inode+0x976/0x10c0
 evict+0x624/0xb50
 ext4_orphan_cleanup+0xc7a/0x14c0
 ext4_fill_super+0x5cb4/0x65c0
 get_tree_bdev_flags+0x430/0x4f0
 vfs_get_tree+0x92/0x2a0
 do_new_mount+0x319/0xdc0
 __se_sys_mount+0x31d/0x420
 do_syscall_64+0x174/0x580
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd58ab9f34a
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd58ba1be58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fd58ba1bee0 RCX: 00007fd58ab9f34a
RDX: 0000200000000180 RSI: 0000200000000080 RDI: 00007fd58ba1bea0
RBP: 0000200000000180 R08: 00007fd58ba1bee0 R09: 0000000000800718
R10: 0000000000800718 R11: 0000000000000246 R12: 0000200000000080
R13: 00007fd58ba1bea0 R14: 00000000000004a7 R15: 000000000000002c
 </TASK>
