Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
xfs: set aside allocation btree blocks from block reservation
The blocks used for allocation btrees (bnobt and countbt) are technically considered free space. This is because as free space is used, allocbt blocks are removed and naturally become available for traditional allocation. However, this means that a significant portion of free space may consist of in-use btree blocks if free space is severely fragmented. On large filesystems with large perag reservations, this can lead to a rare but nasty condition where a significant amount of physical free space is available, but the majority of actual usable blocks consist of in-use allocbt blocks. We have a record of a (~12TB, 32 AG) filesystem with multiple AGs in a state with ~2.5GB or so free blocks tracked across ~300 total allocbt blocks, but effectively at 100% full because the the free space is entirely consumed by refcountbt perag reservation. Such a large perag reservation is by design on large filesystems. The problem is that because the free space is so fragmented, this AG contributes the 300 or so allocbt blocks to the global counters as free space. If this pattern repeats across enough AGs, the filesystem lands in a state where global block reservation can outrun physical block availability. For example, a streaming buffered write on the affected filesystem continues to allow delayed allocation beyond the point where writeback starts to fail due to physical block allocation failures. The expected behavior is for the delalloc block reservation to fail gracefully with -ENOSPC before physical block allocation failure is a possibility. To address this problem, introduce an in-core counter to track the sum of all allocbt blocks in use by the filesystem. Use the new counter to set these blocks aside at reservation time and thus ensure they cannot be reserved until truly available. Since this is only necessary when perag reservations are active and the counter requires a read of each AGF to fully populate, only enforce on perag res enabled filesystems. This allows initialization of the counter at ->pagf_init time because the perag reservation init code reads each AGF at mount time. Signed-off-by: Brian Foster <bfoster@redhat.com>
- Loading branch information