Bug 202383

Summary: btrfs receive deadlock on btrfs_async_run_delayed_refs() and btrfs_tree_lock()
Product: File System Reporter: Eli V (eliventer)
Component: btrfsAssignee: BTRFS virtual assignee (fs_btrfs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: dsterba
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.19.16 Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg with stack traces

Description Eli V 2019-01-22 15:11:22 UTC
Created attachment 280667 [details]
dmesg with stack traces

Running a btrfs receive using btrfs-progs v4.19.1 on linux kernel 4.19.16 seems to have deadlocked the btrfs receive process. Full command is /usr/local/bin/btrfs receive /mirror/, and it's and ssh invocation of a send with just the subvolume being sent i.e. no other options. The filesystem itself doesn't seem to be hung, i.e. can still ls and read files on it, just the receive and a handful of kernel threads are hung. The /proc/stack for the btrfs receive is:

[<0>] btrfs_async_run_delayed_refs+0x115/0x140 [btrfs]
[<0>] __btrfs_end_transaction+0x1d1/0x2d0 [btrfs]
[<0>] btrfs_setattr+0x4ea/0x590 [btrfs]
[<0>] notify_change+0x2f4/0x430
[<0>] do_truncate+0x5e/0x90
[<0>] vfs_truncate+0x195/0x1d0
[<0>] do_sys_truncate+0x59/0xa0
[<0>] do_syscall_64+0x55/0x100
[<0>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
Comment 1 David Sterba 2019-05-21 12:21:42 UTC
Thanks for the report. Fixed by a6279470762c19ba97 "Btrfs: fix deadlock when allocating tree block during leaf/node split", in 5.0.