Repository navigation
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryEnables Btrfs data reclaim through a boot-time tmpfiles drop-in.
Reviews (1) · Last reviewed commit: "Let btrfs reclaim partly used data chunk..." · Reviewed by Greptile |
|
Another incident in the field, plus a confirmation that this PR's settings work on the current Omarchy kernel. Machine: Framework 13 (AMD), Omarchy default layout (LUKS + btrfs root), 3.7 TiB NVMe at 84% full, State when it hit: What it looked like: this machine never reported ENOSPC. The whole desktop froze instead, browser included. Load average was ~120, but CPU, IO and memory pressure (PSI) were all near zero, so btop showed nothing hot. 110 threads were in D state, with writers blocked in Recovery: This PR's settings: I then set I agree with keeping metadata out of it. I had also tried |
|
@dhh @omarchybot the data-chunk reclaim tmpfiles entry and migration from this PR are in #21027, unchanged in intent, next to the update-time check in #15590. Reclaim is what makes new metadata chunks possible. The update stop is what happens when unallocated space and metadata headroom are already under 1 GiB. Please consider closing this as superseded only after #21027 is accepted. Leaving the close to you. |
Refs #15528 (implements its "Possible fixes" option 1)
Problem
On a btrfs root, data chunks can claim the whole device over time. Once nothing is left unallocated, metadata cannot grow, and writes fail with ENOSPC while
dfstill shows plenty of free space. Apps stop starting and the desktop stalls.Hit here on Omarchy with kernel 7.2.5 and a 475 GiB disk:
dfshowed 28 GiB free,Device unallocatedwas 1 MiB and metadata was at 31.93 of 32.45 GiB.btrfs balance start -dusage=0and-dusage=5both relocated 0 of 446 chunks, because a balance needs an unallocated chunk to move data into. It took deleting a 24 GiB file before-dusage=10could relocate 20 chunks and give metadata room again. #15528 and #6553 report the same state.Omarchy configures no reclaim of partly used data block groups, and the kernel leaves it off by default.
Fix
etc/tmpfiles.d/omarchy-btrfs-reclaim.confsetsdynamic_reclaimandperiodic_reclaimto1under/sys/fs/btrfs/*/allocation/data/at every boot. The kernel then compacts partly used data block groups by itself, mostly when unallocated space runs low, so it does little work on a healthy disk.btrfsmaintenancetimer from fix: enable cache trimming and metadata balancing to prevent allocation lockups #6553).wlines accept globs, and a glob that matches nothing is skipped silently, so machines without btrfs, or with a kernel before 6.11, are unaffected.omarchy-settingslike the otheretc/tmpfiles.ddrop-ins.1, so it does nothing on non-btrfs machines and for a second user.This complements #15590, which makes the update guard detect the state, rather than replacing it.
Testing
systemd-tmpfiles --createon a test copy (systemd 262): writes every glob match, creates nothing in a directory without the file, and exits 0 when the glob matches nothing.systemd-tmpfiles --dry-run --createon the drop-in against a real btrfs root resolves both globs to the root filesystem's settings.HOME=$(mktemp -d) bash -euo pipefailexits 0 without prompting when both settings are already1.dynamic_reclaim = 1,periodic_reclaim = 1.