Executive brief
A deadlock condition exists in the Linux kernel's btrfs filesystem when autodefrag and flushoncommit features are enabled together. This can cause the system to hang or become unresponsive when file operations trigger both defragmentation and space reservation routines simultaneously, potentially impacting availability of systems relying on btrfs storage.
Technical details
This is a deadlock vulnerability in the btrfs defragmentation code where the defrag routine attempts to reserve delalloc space while holding dirty and locked folios along with extent range locks. The vulnerability occurs when multiple kernel threads—the metadata space reclaim worker, writeback worker, and cleaner thread—enter a circular wait condition. The defrag operation (btrfs_defrag_file) calls btrfs_delalloc_reserve_space while holding locks, triggering metadata reclaim which attempts to start a transaction, causing threads to wait on each other in a deadlock cycle. This affects systems running with btrfs autodefrag and flushoncommit enabled simultaneously. The issue is resolvable by restructuring the locking order to reserve space before acquiring folios and extent locks.
Affected products
- Linux Linux kernel versions with btrfs defrag autodefrag feature enabled
Timeline
- 2026-09-17: disclosed